From daea174977f6e54513eb9aadfb2d51bde05f3f78 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Fri, 2 Dec 2016 09:51:39 +0100 Subject: [PATCH] update colours and axis range --- atmega32u4/cooler/cooler.c | 53 ++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/atmega32u4/cooler/cooler.c b/atmega32u4/cooler/cooler.c index 02a2c7a..ae8ff3c 100644 --- a/atmega32u4/cooler/cooler.c +++ b/atmega32u4/cooler/cooler.c @@ -17,11 +17,6 @@ // 16 bit color code: red -> 5 bit, green -> 6 bit, blue -> 5 bit #define TOP_BACKGROUND() lcd_set_background(0x03,0x04,0x05) #define BOTTOM_BACKGROUND() lcd_set_background(0x00,0x00,0x00) -#define FIRST_VALUE_FOREGROUND() lcd_set_color(&foreground,0x1f,0x3f,0x0e) -#define SECOND_VALUE_FOREGROUND() lcd_set_color(&foreground,0x0e,0x2e,0x1f) -#define THIRD_VALUE_FOREGROUND() lcd_set_color(&foreground,31, 63/2 ,31/2) -#define FIRST_VALUE_BACKGROUND() lcd_set_background(0x1f,0x3f,0x0e) -#define SECOND_VALUE_BACKGROUND() lcd_set_background(0x0e,0x2e,0x1f) #define AXES_COLOR() lcd_set_color(&foreground,0x1f,0x3f,0x1f) @@ -39,9 +34,9 @@ int16_t lastvalues[4] = {0,0}; volatile uint8_t second, lastsecond; uint8_t ids[NUMSENSORS][8]; int16_t temps[NUMSENSORS] = {-255}; -int16_t set_value = 12*16; -uint8_t output_power_percent = 0; -color_t colors[4]; +int16_t set_value = 22*16; +int8_t output_power_percent = 0; +color_t colors[6]; color_t topback; volatile uint8_t keys_pressed = 0b00000000; @@ -58,16 +53,19 @@ void draw(void) { uint16_t p = valuepointer[0]; do{ for(uint8_t i = 0; i<=1; i++) { - if(i) SECOND_VALUE_FOREGROUND(); - else FIRST_VALUE_FOREGROUND(); + if(i) lcd_use_foreground(colors[2]); + else lcd_use_foreground(colors[0]); + uint16_t y = values[i][p]; y = y*3; - y >>= 4; + y >>= 5; y = 190-y; - lcd_set_pixel_col_xy(c+1,y,background); - lcd_set_pixel_col_xy(c+1,y+1,background); - lcd_set_pixel_col_xy(c,y,foreground); - lcd_set_pixel_col_xy(c,y+1,foreground); + if(yMINY-1) { + lcd_set_pixel_col_xy(c+1,y,background); + lcd_set_pixel_col_xy(c+1,y+1,background); + lcd_set_pixel_col_xy(c,y,foreground); + lcd_set_pixel_col_xy(c,y+1,foreground); + } } p++; if(p>= STORAGESIZE) p = 0; @@ -314,8 +312,8 @@ void printAxes(void) { lcd_set_area_xy(20,319,100,220); lcd_use_background(topback); lcd_set_font(FONT_PROP_16,NORMAL); - lcd_putstr_xy_P(PSTR("-10"),216,0); - lcd_putstr_xy_P(PSTR(" 30"),96,0); + lcd_putstr_xy_P(PSTR("-20"),216,0); + lcd_putstr_xy_P(PSTR(" 60"),96,0); lcd_putstr_xy_P(PSTR("-5"),224,20); lcd_putstr_xy_P(PSTR("0"),224,300); lcd_draw_line(MINX,MINX,MINY-1,MAXY+1); @@ -404,7 +402,9 @@ void showPower(void){ #define POWER_XPOS 62 #define POWER_YPOS 48 TOP_BACKGROUND(); - THIRD_VALUE_FOREGROUND(); + if (output_power_percent < 0) lcd_use_foreground(colors[5]); + if (output_power_percent >= 0) lcd_use_foreground(colors[4]); + output_power_percent = abs(output_power_percent); if(output_power_percent <10){ lcd_set_area_xy(POWER_XPOS,POWER_XPOS+29*2,POWER_YPOS,POWER_YPOS+32); lcd_moveto_xy(POWER_YPOS,POWER_XPOS+29*2); @@ -457,10 +457,13 @@ __attribute__((naked)) int main(void) { keys_init(); PWM_init(); - lcd_set_color(colors+0,0x1f,0x3f,0x0e); - lcd_set_color(colors+1,0x1f,0x3f,0x0e); - lcd_set_color(colors+2,0x1f,0x1f,0x0f); - lcd_set_color(colors+3,0x0e,0x2e,0x1f); + lcd_set_color(colors+0,0x1f,0x3f,0x0e); //yellow 1st + lcd_set_color(colors+1,0x1f,0x3f,0x0e); //yellow 2nd + lcd_set_color(colors+2,0x1f,0x3f,0x1f); //second curve + lcd_set_color(colors+3,0x0e,0x3f,0x0f); //green + lcd_set_color(colors+4,0x0e,0x1f,0x1f); //blue cool + lcd_set_color(colors+5,0x1f,0x09,0x01); //red heat + lcd_set_color(&topback,0x03,0x04,0x05); lcd_command_1(LCD_MIRROR, LCD_BGR | LCD_FLIP_XY); @@ -471,7 +474,7 @@ __attribute__((naked)) int main(void) { printAxes(); - new_set_value(12*16); + new_set_value(set_value); // the main loop @@ -518,9 +521,9 @@ __attribute__((naked)) int main(void) { set_peltier_output(0); output_power_percent = 0; } else { - uint16_t pid_output = pid_calculation( temps[MAINSENSOR] - set_value ); + int16_t pid_output = pid_calculation( temps[MAINSENSOR] - set_value ); set_peltier_output(pid_output); // let PID compute output - output_power_percent = MIN(100,abs(pid_output)/10); // output power in percent (ignore the last 23 from 1023) + output_power_percent = MIN(100,MAX(-100,pid_output/10)); // output power in percent (ignore the last 23 from 1023) } showPower(); uartReport(); -- 2.43.0