diff --git a/firmware/apps/rpn.c b/firmware/apps/rpn.c index 0b1ea45..85ea4ca 100644 --- a/firmware/apps/rpn.c +++ b/firmware/apps/rpn.c @@ -12,8 +12,8 @@ #define STACKSIZE 10 -static unsigned long stack[STACKSIZE]; -static unsigned long buffer=0; +static long stack[STACKSIZE]; +static long buffer=0; static int bufferdirty=0; static unsigned int stacki=0; @@ -109,7 +109,7 @@ void rpn_draw(){ //! A button has been pressed for the calculator. int rpn_keypress(char ch){ - unsigned long i, j; + long i, j; //Do nothing on a keyup event. if(!ch) diff --git a/firmware/lcdtext.c b/firmware/lcdtext.c index 0eee549..60ecf55 100644 --- a/firmware/lcdtext.c +++ b/firmware/lcdtext.c @@ -43,6 +43,8 @@ const int lcdmap[10][8]={ //! Bit flags for each of the eight segments. enum lcdmappos {A=1, B=2, C=4, D=8, E=0x10, F=0x20, G=0x40, DP=0x80}; + + //! Font for numbers. const int numfont[]={ A|B|C|D|E|F, //0 @@ -125,6 +127,10 @@ void lcd_char(int pos, char c){ }else if(c==' '){ lcd_cleardigit(pos); return; + }else if(c=='-'){ + lcd_cleardigit(pos); + DRAWPOINT(lcdmap[pos][6]); //Set the G segment. + return; }else if(c=='.'){ lcd_cleardigit(pos); setperiod(pos,1); @@ -159,7 +165,7 @@ void lcd_string(const char *str){ } //! Draws a decimal number on the screen. -void lcd_number(long num){ +void lcd_unumber(long num){ static long oldnum=0; static unsigned long bcd=0; @@ -180,6 +186,17 @@ void lcd_number(long num){ lcd_hex(bcd); } + +//! Draws a decimal number on the screen. +void lcd_number(long num){ + if(num<0){ + lcd_unumber(0-num); + lcd_char(7,'-'); + }else{ + lcd_unumber(num); + } +} + //! Draws hex on the screen. void lcd_hex(long num){ /* So in an ideal world, we'd have characters arranged nicely into