#include "ST7735s.h" #include #include "spi_master_dma_interrupt.h" #include "public.h" #include "fpc.h" #include "sim_eeprom.h" #define ST7735_SLPOUT 0x11 #define ST7735_FRMCTR1 0xB1 #define ST7735_FRMCTR2 0xB2 #define ST7735_FRMCTR3 0xB3 #define ST7735_INVCTR 0xB4 #define ST7735_PWCTR1 0xC0 #define ST7735_PWCTR2 0xC1 #define ST7735_PWCTR3 0xC2 #define ST7735_PWCTR4 0xC3 #define ST7735_PWCTR5 0xC4 #define ST7735_VMCTR1 0xC5 #define ST7735_COLMOD 0x3A #define ST7735_GMCTRP1 0xE0 #define ST7735_GMCTRN1 0xE1 #define ST7735_NORON 0x13 #define ST7735_DISPON 0x29 #define ST7735_CASET 0x2A #define ST7735_RASET 0x2B #define ST7735_RAMWR 0x2C #define ST7735_INVOFF 0x20 #define ST7735_INVON 0x21 #define ST7735_MADCTL 0x36 #define ST7735_MADCTL_MX 0x40 #define ST7735_MADCTL_MY 0x80 #define ST7735_MADCTL_MV 0x20 #define ST7735_XOFFSET 0x02 //如果用80*160 最左边第二列的ram有问题,屏幕有黑线 //故用82*160的ram 图片的x坐标记加漂移 偶现,可能是不同屏幕的素质不同导致 #define PLATFORM_DelayMS DELAY_Ms static uint8_t DMA_ram_buffer[4096]; float breath_down[10] = {0.900000, 0.810000, 0.729000, 0.656100, 0.590490, 0.531441, 0.478297, 0.430467, 0.387420, 0.348678}; //float breath_up[10] = {1.250000,1.562500,1.953125,2.441406,3.051758,3.814697,4.768372,5.960464,7.450581,9.313226}; u8 debug_flag = 0; float Cclt_Power(float a, uint8_t b) { uint8_t i; float temp; temp = 1.0; for(i=0;i> (16-(j%3)*8)& 0xFF; // } // ST7735_WriteData((uint8_t *)DMA_ram_buffer,4095); // } // if(remainder) // { // for(j=0;j> (16-(j%3)*8)& 0xFF; // } // ST7735_WriteData((uint8_t *)DMA_ram_buffer,4096); // } uint8_t buff[width * 3]; uint16_t i = 0; for (i = 0; i < width; i++) { buff[i * 3] = color >> 16& 0xFF; buff[i * 3 + 1] = color >>8 & 0xFF; buff[i * 3 + 2] = color & 0xFF; } ST7735_SetAddressWindow(x, y, x + width - 1, y + height - 1); ST7735_WriteCommand(ST7735_RAMWR); for (i = 0; i < height; i++) { ST7735_WriteData(buff, 3* width); } } void ST7735_DrawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { uint8_t buff[width * 2]; uint16_t i = 0; for (i = 0; i < width; i++) { buff[i * 2] = color >> 8; buff[i * 2 + 1] = color & 0xFF; } ST7735_SetAddressWindow(x, y, x + width - 1, y + height - 1); ST7735_WriteCommand(ST7735_RAMWR); // Write the color data for (i = 0; i < height; i++) { ST7735_WriteData(buff, sizeof(uint16_t) * width); } } void ST7735_FillScreen(uint16_t color) { ST7735_DrawRectangle(0, 0, ST7735_WIDTH, ST7735_HEIGHT, color); } void ST7735_FillScreen_666(uint32_t color) { ST7735_DrawRectangle_666(0, 0, ST7735_WIDTH, ST7735_HEIGHT, color); } void ST7735_Clear_Part_Window(uint16_t x, uint16_t y, uint16_t width, uint16_t height,uint32_t color) { ST7735_DrawRectangle_666(x, y, width, height, color); } void ST7735_ImageBreath_down(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint8_t *image,uint16_t lenth,uint8_t k) { uint16_t i,j,time,remainder; remainder = lenth%4096; time = lenth/4096; ST7735_SetAddressWindow(x, y, x + width - 1, y + height - 1); ST7735_WriteCommand(ST7735_RAMWR); for(i=0;i=80) { pic_clock = 0; //////////////////// switch(pic_rank) { case 12: ST7735_DrawFlashImage(26,30,27,113,9153,pic_rank); pic_rank++; break; case 11: ST7735_DrawFlashImage(26,30,27,113,9153,pic_rank); pic_rank++; break; case 10: ST7735_DrawFlashImage(26,30,27,113,9153,pic_rank); pic_rank++; break; case 9: ST7735_DrawFlashImage(26,30,27,113,9153,pic_rank); pic_rank++; break; case 8: ST7735_DrawFlashImage(26,30,27,113,9153,pic_rank); pic_rank++; break; case 7: ST7735_DrawFlashImage(26,30,27,113,9153,pic_rank); pic_rank++; break; case 6: ST7735_DrawFlashImage(26,30,27,113,9153,pic_rank); pic_rank++; break; case 5: ST7735_DrawFlashImage(26,30,27,113,9153,pic_rank); pic_rank++; break; case 4: ST7735_DrawFlashImage(26,30,27,113,9153,pic_rank); pic_rank++; break; case 3: ST7735_DrawFlashImage(26,30,27,113,9153,pic_rank); pic_rank++; break; case 0: first_flag ++; if(first_flag==10) { first_flag = 0; pic_rank = 3; } break; case 13: pic_rank = 0; restart = 0; break; default: break; } ////////////////////清屏+小图的方法 /* switch(pic_rank) { case 12: ST7735_Clear_Part_Window(26,30,27,113,BG_COLOR); ST7735_DrawFlashImage(35,64,10,45,1350,pic_rank); pic_rank++; break; case 11: ST7735_Clear_Part_Window(26,30,27,113,BG_COLOR); ST7735_DrawFlashImage(34,61,12,51,1836,pic_rank); pic_rank++; break; case 10: ST7735_Clear_Part_Window(26,30,27,113,BG_COLOR); ST7735_DrawFlashImage(33,58,14,58,2436,pic_rank); pic_rank++; break; case 9: ST7735_Clear_Part_Window(26,30,27,113,BG_COLOR); ST7735_DrawFlashImage(32,54,15,65,2925,pic_rank); pic_rank++; break; case 8: ST7735_Clear_Part_Window(26,30,27,113,BG_COLOR); ST7735_DrawFlashImage(31,51,17,72,3672,pic_rank); pic_rank++; break; case 7: ST7735_Clear_Part_Window(26,30,27,113,BG_COLOR); ST7735_DrawFlashImage(31,47,18,79,4266,pic_rank); pic_rank++; break; case 6: ST7735_Clear_Part_Window(26,30,27,113,BG_COLOR); ST7735_DrawFlashImage(30,44,20,85,5100,pic_rank); pic_rank++; break; case 5: ST7735_Clear_Part_Window(26,30,27,113,BG_COLOR); ST7735_DrawFlashImage(29,41,22,92,6072,pic_rank); pic_rank++; break; case 4: ST7735_Clear_Part_Window(26,30,27,113,BG_COLOR); ST7735_DrawFlashImage(28,37,23,99,6831,pic_rank); pic_rank++; break; case 3: ST7735_DrawFlashImage(26,30,27,113,9153,pic_rank); pic_rank++; break; case 0: first_flag ++; if(first_flag==10) { first_flag = 0; pic_rank = 3; } break; case 13: pic_rank = 0; restart = 0; break; default: break; } */ } } void animation_show_v(void) { static u8 last_battery_level; static u8 x_start =0; static u8 y_start =0; static u8 time_count = 0; static bool charge_start_flag = 0; static bool flicker_flag = 0; u8 i; if(logo2_flag == 0 ) { restart = 0; logo2_flag =1 ; flicker_flag = 0; pic_clock = 0; time_count = 0; charge_start_flag = 0; last_battery_level = g_work.m_conditon.m_conditon.V_conditon; ST7735_FillScreen_666(BG_COLOR); ST7735_DrawFlashImage(11,5,58,13,2262,1); for(i = 0;i<16;i++) { ST7735_DrawFlashImage(10,20+i*8,60,5,900,16); } if(last_battery_level > 0 ) { for(i = 1;i<=last_battery_level;i++) { ST7735_DrawFlashImage(10,12+i*8,60,5,900,15); } if(is_charging)//充电动画,先确定初始位置 { ST7735_DrawFlashImage(10,12+(i-1)*8,60,5,900,13); charge_start_flag = 1; } } else { if(is_charging)//充电动画,先确定初始位置 { charge_start_flag = 1; } } x_start = 69; y_start = 12+(i-1)*8; } if(is_charging) { if(charge_start_flag==0) { charge_start_flag = 1; logo2_flag = 0; return ; } if(last_battery_level == 0) { return ; } if(pic_clock>=33 && time_count<60) { ST7735_Draw_BatLevel(x_start-time_count,y_start); time_count++; pic_clock = 0; } if(time_count>=60) { ST7735_DrawFlashImage(10,y_start,60,5,900,13); time_count = 0; if(last_battery_level==(g_work.m_conditon.m_conditon.V_conditon+1)) { logo2_flag = 0; } } } else { if(charge_start_flag==1)//充电更新 { logo2_flag = 0; charge_start_flag = 0; return ; } if(last_battery_level<16 && last_battery_level>=13) { if(pic_clock >= 400) { if(flicker_flag==0) { for(i = last_battery_level;i<16;i++) { ST7735_DrawFlashImage(10,20+i*8,60,5,900,15); } flicker_flag = 1; } else { for(i = last_battery_level;i<16;i++) { ST7735_DrawFlashImage(10,20+i*8,60,5,900,16); } flicker_flag = 0; } pic_clock = 0; } } else { pic_clock = 0; flicker_flag = 0; } } } void animation_temp_on(void) { static u8 up_down_flag = 0; static u8 up_down_time = 0; if(logo3_flag == 0 ) { restart = 0; ST7735_FillScreen_666(BG_COLOR); ST7735_DrawFlashImage(11,5,58,13,2262,1); ST7735_DrawFlashImage(33,22,12,123,4428,17); logo3_flag =1 ; g_work.m_work_flag._beep_flag = 1; pic_clock = 0; } if(pic_clock>=50) { if(up_down_flag == 0) { if(up_down_time<10) { #ifdef package_3 ST7735_ImageBreath_down(33,22,12,123,(const unsigned char *)gImage_17,4428,up_down_time); #endif up_down_time++; } if(up_down_time == 10) { up_down_time = 0; up_down_flag = 1; } } else { if(up_down_time<10) { #ifdef package_3 ST7735_ImageBreath_down(33,22,12,123,(const unsigned char *)gImage_17,4428,(9-up_down_time)); #endif up_down_time++; } if(up_down_time == 10) { up_down_time = 0; up_down_flag = 0; } } pic_clock = 0; } } void animation_smoking(void) { static u8 times = 0; if(logo4_flag == 0 ) { restart = 0; ST7735_FillScreen_666(BG_COLOR); ST7735_DrawFlashImage(11,5,58,13,2262,1); ST7735_DrawFlashImage(33,22,12,123,4428,17); ST7735_DrawFlashImage(33,141,12,5,180,19); logo4_flag =1 ; times = 0; pic_clock = 0; g_work.m_work_flag._beep_flag = 2; } if(pic_clock >= (g_work.m_set_other_hot.set_all_time-g_work.m_set_other_hot.set_order_time-10)*1000/78) { if(times<=78) { ST7735_DrawFlashImage(33,141-times,12,5,180,19); times++; } if(times>78) { times = 0; } pic_clock = 0; } } void animation_heat_over(void) { static u8 up_down_flag = 0; static u8 up_down_time = 0; static bool over_flag = 0; if(logo5_flag == 0 ) { restart = 0; ST7735_DrawFlashImage(11,5,58,13,2262,1); ST7735_DrawFlashImage(33,22,12,49,1764,18); pic_clock = 0; logo5_flag =1 ; g_work.m_work_flag._beep_flag = 2; over_flag = 0; } if(keep_temp_time) { if(pic_clock>=50) { if(up_down_flag == 0) { if(up_down_time<10) { #ifdef package_3 ST7735_ImageBreath_down(33,22,12,49,(const unsigned char *)gImage_18,1764,up_down_time); #endif up_down_time++; } if(up_down_time == 10) { up_down_time = 0; up_down_flag = 1; } } else { if(up_down_time<50) { #ifdef package_3 ST7735_ImageBreath_down(33,22,12,49,(const unsigned char *)gImage_18,1764,(9-up_down_time)); #endif up_down_time++; } if(up_down_time == 10) { up_down_time = 0; up_down_flag = 0; } } pic_clock = 0; } } else { if(over_flag==0) { ST7735_DrawFlashImage(33,22,12,49,1764,20); over_flag =1; } } }