void out_text(unsigned char sz, unsigned char const *ptr) { for (unsigned char p = 0; p != WIDTH; ++p) { if (p < sz) { LCD_DrawChar(p, 0, ptr[p]); } else { LCD_DrawChar(p, 0, ' '); } } }
void fill_glass(int sel) { disable_joystick(); // Disable user input LCD_Clear(); LCD_DrawString(2, 8, (u8*)"Filling...", 10); LCD_DrawString(4, 8, (u8*)drink[sel], strlen(drink[sel]));; set_all_valves(0); // Safety check; close all valves int empty_weight = get_weight(); switch(sel) { case 0: // Tequila Sunrise; 30.75% Tequila, 61.5% Orange Juice, 7.75% Grenadine LCD_DrawChar(0, 0, '1'); fill_liquid(TEQUILA, (empty_weight + 0.3075*MAX_WEIGHT)); LCD_DrawChar(0, 0, '2'); fill_liquid(ORANGE, (empty_weight + 0.9225*MAX_WEIGHT)); LCD_DrawChar(0, 0, '3'); fill_liquid(GRENADINE, (empty_weight + MAX_WEIGHT)); break; case 1: // The Gilbert; 58% Vodka, 30% Soda, 12% Orange Juice LCD_DrawChar(0, 0, '1'); fill_liquid(VODKA, (empty_weight + 0.58*MAX_WEIGHT)); LCD_DrawChar(0, 0, '2'); fill_liquid(SODA, (empty_weight + 0.88*MAX_WEIGHT)); LCD_DrawChar(0, 0, '3'); fill_liquid(ORANGE, (empty_weight + MAX_WEIGHT)); break; case 2: // Pink Polar Bear; 58% Vodka, 42% Grenadine LCD_DrawChar(0, 0, '1'); fill_liquid(VODKA, (empty_weight + 0.58*MAX_WEIGHT)); LCD_DrawChar(0, 0, '2'); fill_liquid(GRENADINE, (empty_weight + MAX_WEIGHT)); break; case 3: // Screwdriver; 48% Vodka, 52% Orange Juice LCD_DrawChar(0, 0, '1'); fill_liquid(VODKA, (empty_weight + 0.48*MAX_WEIGHT)); LCD_DrawChar(0, 15*8, '2'); fill_liquid(ORANGE, (empty_weight + MAX_WEIGHT)); break; default: break; } set_all_valves(0); // Safety check; close all valves LCD_Clear(); LCD_DrawString(1, 8, (u8*)"Enjoy...", 8); LCD_DrawString(3, 8, (u8*)"Press Joystick", 14); LCD_DrawString(5, 8, (u8*)"for new drink", 13); enable_joystick(); // Enable user input }
/*------------------------------------------------------------------------------------*/ void DrawIcon(IconName _IconName, IconStatus _Status) { LCD_SetColors(LCD_COLOR_BLACK, LCD_COLOR_WHITE); switch (_IconName) { case Icon_TopBar_Clock: LCD_DrawChar(3, (20-Image_TopBar_Clock.height)/2, (ptImage)&Image_TopBar_Clock); break; case Icon_TopBar_Battery: LCD_DrawBMP(297, (20-Image_TopBar_Battery.height)/2, (ptImage)&Image_TopBar_Battery, 0); break; case Icon_TopBar_FlyTime: LCD_DrawBMP(142, (20-Image_TopBar_FlyTime.height)/2, (ptImage)&Image_TopBar_FlyTime, 0); break; case Icon_TopBar_Temper: LCD_DrawBMP(214, (20-Image_TopBar_Temper.height)/2, (ptImage)&Image_TopBar_Temper, 0); break; case Icon_TopBar_DesatTime: LCD_DrawBMP(74, (20-Image_TopBar_DesatTime.height)/2, (ptImage)&Image_TopBar_DesatTime, 0); break; case Icon_BottomBar_ArrowUp: LCD_DrawBMP(112, ((20-Image_BottomBar_ArrowUp.height)/2)+220, (ptImage)&Image_BottomBar_ArrowUp, 0); break; case Icon_BottomBar_ArrowDown: LCD_DrawBMP(185, ((20-Image_BottomBar_ArrowUp.height)/2)+220, (ptImage)&Image_BottomBar_ArrowUp, 2); break; case Icon_BottomBar_ArrowLeft: LCD_DrawBMP(40, ((20- Image_BottomBar_ArrowLeft.height)/2)+220, (ptImage)&Image_BottomBar_ArrowLeft, 0); break; case Icon_BottomBar_Select: LCD_DrawBMP(258, ((20-Image_BottomBar_Select.height)/2)+220, (ptImage)&Image_BottomBar_Select, 0); break; case Icon_HomeMenu_GoDive: switch(_Status) { case Select: LCD_SetColors(Black, White); LCD_FillRect(26, 30, 57, 57, Blue); break; default: LCD_SetColors(White, Black); LCD_FillRect(26, 30, 57, 57, Black); break; } LCD_DrawChar((26+((57-Image_HomeMenu_GoDive.width)/2)), 34,(ptImage)&Image_HomeMenu_GoDive); break; default: LCD_FillRect(0, 120, 120, 3, LCD_COLOR_RED);//Error notification break; } }
void write_lcd(int selected) { LCD_Clear(); LCD_DrawString(0, 8, (u8*)drink[0], strlen(drink[0])); LCD_DrawString(2, 8, (u8*)drink[1], strlen(drink[1])); LCD_DrawString(4, 8, (u8*)drink[2], strlen(drink[2])); LCD_DrawString(6, 8, (u8*)drink[3], strlen(drink[3])); LCD_DrawChar(2*selected, 0, '-'); }
void LOG_str(const u8* string, u16 length) { for( u8 i=0; i<length+1; i++) { if( i==length) LCD_DrawChar(LOG_countery,LOG_counterx,'_'); else LCD_DrawChar(LOG_countery,LOG_counterx,string[i]); LOG_counterx += LOG_charw; if( LOG_counterx >= LOG_width) { LOG_counterx = 0; LOG_countery += LOG_charh; } if( LOG_countery >= LOG_height) { LOG_countery = 0; } } }
void down(void) { char hex[]="0123456789ABCDEF"; int det=0, cursor_pos=0, decreased=0, offset=0; det= detect_number(); if (det == 0) decreased = 9; else decreased = det - 1; cursor_pos= detect_cursor(); if(cursor_pos==1 || cursor_pos==2) offset= 8+cursor_pos*8; else if (cursor_pos==3 || cursor_pos==4) offset= 16+cursor_pos*8; LCD_EraseChar(2, offset); LCD_DrawChar(2, offset, hex[decreased]); }
/** * @brief This function increase the value. * @param None * @retval None */ void up(void) { char hex[]="0123456789ABCDEF"; int det=0, cursor_pos=0, rised=0, offset=0; det= detect_number(); if (det == 9) rised = 0; else rised = det + 1; cursor_pos= detect_cursor(); if(cursor_pos==1 || cursor_pos==2) offset= 8+cursor_pos*8; else if (cursor_pos==3 || cursor_pos==4) offset= 16+cursor_pos*8; LCD_EraseChar(2, offset); LCD_DrawChar(2, offset, hex[rised]); }
/******************************************************************************* * Function Name : LCD_DrawString * Description : draw a string of length at certain postion * Input : Xpage -- postion of page YCol -- postion of colomn c -- pointer to the string to be displayed length -- length of string * Output : None * Return : 0 -- failure 1 -- success *******************************************************************************/ u8 LCD_DrawString(u8 Xpage, u8 YCol, u8 *c, u8 length) { #ifndef NO_LCD u8 len = length; u8* pOffset = c; if ((128-YCol)<8*length) return 0; else { while(len--) { LCD_DrawChar(Xpage, YCol, *pOffset); YCol +=8; pOffset++; } return 1; } #else return 1; #endif }
/******************************************************************************* * Function Name : LCD_DisplayChar * Description : Displays one character (16dots width, 24dots height). * Input : - Line: the Line where to display the character shape . * This parameter can be one of the following values: * - Linex: where x can be 0..9 * - Column: start column address. * - Ascii: character ascii code, must be between 0x20 and 0x7E. * Output : None * Return : None *******************************************************************************/ void LCD_DisplayChar(u8 Line, u16 Column, u8 Ascii) { Ascii -= 32; LCD_DrawChar(Line, Column, &ASCII_Table[Ascii * 24]); }
/** * @brief Displays one character. * @param Xpos: Start column address * @param Ypos: Line where to display the character shape. * @param Ascii: Character ascii code * This parameter must be a number between Min_Data = 0x20 and Max_Data = 0x7E * @retval None */ void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii) { LCD_DrawChar(Xpos, Ypos, &DrawProp.pFont->table[(Ascii-' ') *\ DrawProp.pFont->Height * ((DrawProp.pFont->Width + 7) / 8)]); }
/** * @brief Displays one character (16dots width, 24dots height). * @param Line: the Line where to display the character shape . * This parameter can be one of the following values: * @arg Linex: where x can be 0..9 * @param Column: start column address. * @param Ascii: character ascii code, must be between 0x20 and 0x7E. * @retval None */ void LCD_DisplayChar(uint8_t Line, uint16_t Column, uint8_t Ascii) { Ascii -= 32; LCD_DrawChar(Line, Column, &ASCII_Table[Ascii * 24]); }
void OnyxWalker_Task(void) { unsigned short now = MY_GetTicks(); if (now < lastTicks) { ++numWraps; LCD_DrawUint(numWraps, WIDTH-7, 3); } if (now - lastVolts > 15000) { lastVolts = now; ++voltBlink; if ((power_cvolts > 1320 && !power_failure) || (voltBlink & 1)) { LCD_DrawFrac(power_cvolts, 2, 0, 3); LCD_DrawChar(' ', 6, 3); LCD_DrawChar('V', 7, 3); PORTC &= ~(1 << 6); } else { LCD_DrawChar(' ', 0, 3); for (unsigned char i = 1; i != 8; ++i) { LCD_DrawChar('-', i, 3); } if (!(voltBlink & 15) && power_cvolts > 0) { PORTC |= (1 << 6); } else { PORTC &= ~(1 << 6); } } } lastTicks = now; LCD_Flush(); if (lastTicks - last_cvolts > 10000) { power_tick(); last_cvolts = lastTicks; } if (USB_DeviceState != DEVICE_STATE_Configured) { return; } /* see if host has requested data */ Endpoint_SelectEndpoint(DATA_RX_EPNUM); Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN); epic = Endpoint_IsConfigured(); epiir = epic && Endpoint_IsINReady(); epirwa = epiir && Endpoint_IsReadWriteAllowed(); if (epirwa && (in_packet_ptr || (now - last_flush > FLUSH_TICK_INTERVAL))) { last_flush = now; if (in_packet_ptr == 0) { in_packet_ptr = 1; // repeat the last received serial } // send packet in for (unsigned char ch = 0; ch < in_packet_ptr; ++ch) { Endpoint_Write_8(in_packet[ch]); } Endpoint_ClearIN(); in_packet_ptr = 0; } /* see if there's data from the host */ Endpoint_SelectEndpoint(DATA_TX_EPNUM); Endpoint_SetEndpointDirection(ENDPOINT_DIR_OUT); MY_SetLed(LED_act, false); if (Endpoint_IsConfigured() && Endpoint_IsOUTReceived() && Endpoint_IsReadWriteAllowed()) { uint8_t n = Endpoint_BytesInEndpoint(); if (n > sizeof(out_packet)) { MY_Failure("OUT too big", n, sizeof(out_packet)); } out_packet_ptr = 0; MY_SetLed(LED_act, true); while (n > 0) { epic = Endpoint_Read_8(); out_packet[out_packet_ptr++] = epic; --n; } Endpoint_ClearOUT(); dispatch_out(); } }