/*============================================================================*/ void LCD_16x2_ScreenOut(const char *LCDRow1, const char *LCDRow2, unsigned char clear_screen){ if (clear_screen) LCD_Clear(); LCD_Goto(0,0); LCD_Puts(LCDRow1); LCD_Goto(1,0); LCD_Puts(LCDRow2); }
int main() { char uartBuffer[80]; char lcdBuffer[16]; UART_1_Start(); UART_1_UartPutString("Sequencer Board Test\r\n"); // Sequence Boardをリセット Pin_I2C_Reset_Write(0u); CyDelay(1); Pin_I2C_Reset_Write(1u); /* Init I2C */ I2CM_Start(); CyDelay(1500); CyGlobalIntEnable; LCD_Init(); LCD_Clear(); LCD_Puts("Sequencer Board"); CyDelay(1000); for(;;) { if (readSequencerBoard() == I2C_TRANSFER_CMPLT) { sprintf(uartBuffer, "%d %d %d %d %d %d ", sequencerRdBuffer[0], sequencerRdBuffer[1], sequencerRdBuffer[2], sequencerRdBuffer[3], sequencerRdBuffer[4], sequencerRdBuffer[5] ); UART_1_UartPutString(uartBuffer); } else { UART_1_UartPutString("I2C Master Sequencer Read Error.\r\n"); } if (writeSequencerBoard() == I2C_TRANSFER_CMPLT) { sprintf(uartBuffer, "%d\r\n", sequencerWrBuffer[0]); UART_1_UartPutString(uartBuffer); } else { UART_1_UartPutString("I2C Master Sequencer Write Error.\r\n"); } sprintf(lcdBuffer, "%d", sequencerWrBuffer[0]); LCD_Clear(); LCD_Puts(lcdBuffer); sequencerWrBuffer[0] = inc_within_uint8(sequencerWrBuffer[0], 16, 0); CyDelay(125); } }
inline void inputRepaintF(float value) { //if need, we clear display LCD_Goto(1, 0);//print title LCD_Puts(activeItem->Text); LCD_Goto(2, 1); LCD_Puts("Параметр:"); LCD_Putc(' '); LCD_PutFloat(value);//print value }
inline void actionRepaint(devstate acState) { //if need, we clear display LCD_Goto(1, 0);//print title LCD_Puts(activeItem->Text); LCD_Goto(2, 2); LCD_Puts("Состояние:"); LCD_Puts(" "); LCD_Goto(12, 2); if(acState == ENABLE_STATE) LCD_Puts("Вкл.");//print value else if(acState == DISABLE_STATE) LCD_Puts("Откл.");//print value }
/******************************************************************************* * ?????? * *******************************************************************************/ void main() { OSCCON = 0b01110010 ; // ???????8?????? OPTION_REG = 0b00000000 ; // ????I/O??????????????? ANSELA = 0b00000000 ; // ??????????????????I/O?????? TRISA = 0b00000110 ; // ???RA1(SCL)/RA2(SDA)????(RA3?????) WPUA = 0b00000000 ; // RA1/RA2??????????????? PORTA = 0b00000000 ; // ????????(??LOW???) RA4 = 0; __delay_ms(500); RA4 = 1; __delay_ms(500); int i = 0; // ?????????(????100KHz) InitI2C_Master(1) ; // ?????????????? // ICON OFF,??????(0-63),VDD=3.3V???,LCD?8??? LCD_Init(LCD_NOT_ICON,32,LCD_VDD3V,8) ; while(1) { if(RA4 == 0) i++; LCD_SetCursor(0,0) ; // ????????? LCD_Puts("-JP7FKF-") ; LCD_SetCursor(0,1) ; // ????????? LCD_Putc(i+0x30) ; } }
int main() { CyGlobalIntEnable; /* Enable global interrupts. */ I2CM_LCD_Start(); // akizuki AQM1602(5V) //LCD_Init(0x3e, 12); // akizuki AQM1602(3.3V) LCD_Init(0x3e, 32); CyDelay(100); LCD_Puts("Hello PSoC 5LP"); for(;;) { LCD_SetPos(0, 1); LCD_Puts("Prototyping Kit "); } }
void lcdRepaintMenu() { LCD_Clear(); /* For first we print the name of parent menu */ if(activeItem->Parent == (void*)&NULL_ENTRY){ LCD_Goto(1, 0); LCD_Puts(MAIN_MENU_TEXT); } else { menuItem *parItem = (void*)activeItem->Parent; LCD_Goto(1, 0); LCD_Puts(parItem->Text); } /*After that we print current item and two others besides it */ menuItem *parItem = (void*)activeItem; //come back to first item in current page int i; if(activeItem->Index <= FIELDS_NUMBER-1) i = activeItem->Index;//if we situated in 1-st page else i = activeItem->Index % FIELDS_NUMBER;//if we situated in the one of others pages for(; i > 0; i--) parItem = (void*)parItem->Previous; //and print points items on display for(i = 0; i < FIELDS_NUMBER; i++) { LCD_Goto(2, i+1); LCD_Puts(parItem->Text); if((void*)parItem->Next != (void*)&NULL_ENTRY) parItem = (void*)parItem->Next; else break; } }
void timeset(uint8_t *value, uint8_t min_num, uint8_t max_num, uint8_t Reg, uint8_t column, uint8_t row) { sw_RA0.flags = 0; sw_RA1.flags = 0; while (!sw_RA0.flag.press) { if (cnt_t1 % 16 >= 8) { LCD_SetCursor(column, row); // 表示位置を設定する LCD_Puts(" "); } else { *value = RTC_Read(Reg); display(); LCD_SetCursor(column, row); // 表示位置を設定する LCD_Putc(*value / 16 + '0'); LCD_Putc(*value % 16 + '0'); } if (sw_RA1.flag.press) { sw_RA1.flag.press = 0; uint8_t t = *value % 16 + (*value / 16)*10; if (t >= max_num) { t = min_num; } else { t++; } *value = t % 10 + (t / 10)* 16; RTC_Write(Reg, *value); } if (sw_RA1.flag.long_holding_1) { sw_RA1.flag.long_holding_1 = 0; uint8_t t = *value % 16 + (*value / 16)*10; if (t + 9 >= max_num) { t = t % 10; } else { t += 10; } *value = t % 10 + (t / 10)* 16; RTC_Write(Reg, *value); } } sw_RA0.flags = 0; }
void alCleaning() { LCD_Clear(); LCD_Goto(1, 0); LCD_Puts("Cleaning..."); //enable screw ignition enableDev(&screwIgn); startTimerDevice(&ScrewIgnTimer, 15); while(ScrewIgnTimer.CurrentState == ENABLE_TIM);//wait while Screw ign timer working enableDev(&outFireBar); startTimerDevice(&FireBarTimer,15); while(FireBarTimer.CurrentState == ENABLE_TIM);//wait while FireBar timer working // workState = END_WORK; //here will be fan /*enableDev(&outFireBar); startTimerDevice(&FireBarTimer,15); while(FireBarTimer.CurrentState == ENABLE_TIM);//wait while FireBar timer working */ }
void LCD_Update() { _INT3IP = 0; // Disable INT3 for temporary AdcData data = ADC_GetData(); LCD_Home(); switch(page) { case 1: LCD_Puts("Load Data "); LCD_Row(2); if (data.vLoadRms != 0 && data.iLoadRms != 0) { sprintf(lcdChar, "V:%-7.1f I:%-5.3f ", data.vLoadRms, data.iLoadRms); LCD_Puts(lcdChar); LCD_Row(3); if (data.pfLoad != 0) sprintf(lcdChar, "P:%-7.3f PF:%-6.2f ", data.pLoad, data.pfLoad); else sprintf(lcdChar, "P:%-7.3f PF:- ", data.pLoad); LCD_Puts(lcdChar); } else { if (data.vLoadRms != 0 && data.iLoadRms == 0) { sprintf(lcdChar, "V:%-7.1f I:0 ", data.vLoadRms); LCD_Puts(lcdChar); } else if (data.vLoadRms == 0 && data.iLoadRms != 0) { sprintf(lcdChar, "V:0 I:%-5.3f ", data.iLoadRms); LCD_Puts(lcdChar); } else { LCD_Puts("V:0 I:0 "); } LCD_Row(3); LCD_Puts("P:0 PF:- "); } LCD_Row(4); if (data.eLoad != 0) { sprintf(lcdChar, "E:%.4Lf kWh ", data.eLoad); LCD_Puts(lcdChar); } else LCD_Puts("E:0 kWh "); break; case 3: LCD_Puts("PV Data "); LCD_Row(2); if (data.vPV != 0 && data.iPV != 0) { sprintf(lcdChar, "V:%-6.2f I:%-6.2f ", data.vPV, data.iPV); LCD_Puts(lcdChar); } else if (data.vPV != 0 && data.iPV == 0) { sprintf(lcdChar, "V:%-6.2f I:0 ", data.vPV); LCD_Puts(lcdChar); } else if (data.vPV == 0 && data.iPV != 0) { sprintf(lcdChar, "V:0 I:%-6.2f ", data.iPV); LCD_Puts(lcdChar); } else LCD_Puts("V:0 I:0 "); LCD_Row(3); if (data.pPv != 0) { sprintf(lcdChar, "P:%-7.2f ", data.pPv); LCD_Puts(lcdChar); } else LCD_Puts("P:0 "); LCD_Row(4); if (data.ePv != 0) { sprintf(lcdChar, "E:%.4Lf kWh ", data.ePv); LCD_Puts(lcdChar); } else LCD_Puts("E:0 kWh "); break; case 2: LCD_Puts("Battery Data "); LCD_Row(2); if (data.vBatt != 0 && data.iBatt != 0) { sprintf(lcdChar, "V:%-6.2f I:%-6.2f ", data.vBatt, data.iBatt); LCD_Puts(lcdChar); } else if (data.vBatt != 0 && data.iBatt == 0) { sprintf(lcdChar, "V:%-6.2f I:0 ", data.vBatt); LCD_Puts(lcdChar); } else if (data.vBatt == 0 && data.iBatt != 0) { sprintf(lcdChar, "V:0 I:%-6.2f ", data.iBatt); LCD_Puts(lcdChar); } else LCD_Puts("V:0 I:0 "); LCD_Row(3); if (data.pBatt != 0) { if (data.percentBatt != 0) { sprintf(lcdChar, "P:%-6.2f %%Batt:%-5.2f", data.pBatt, data.percentBatt); LCD_Puts(lcdChar); } else { sprintf(lcdChar, "P:%-6.2f %%Batt:0 ", data.pBatt); LCD_Puts(lcdChar); } } else { if (data.percentBatt != 0) { sprintf(lcdChar, "P:0 %%Batt:%-5.2f", data.percentBatt); LCD_Puts( lcdChar); } LCD_Puts("P:0 %Batt:0 "); } LCD_Row(4); if (data.eBatt != 0) { sprintf(lcdChar, "E:%.4Lf kWh ", data.eBatt); LCD_Puts(lcdChar); } else LCD_Puts("E:0 kWh "); break; case 0: LCD_Puts(RTCC_GetLcdTime()); LCD_Row(2); LCD_Puts(RTCC_GetLcdDate()); LCD_Row(3); sprintf(lcdChar, "%%Eff: %-6.2f ", data.efficiency); LCD_Puts(lcdChar); LCD_Row(4); LCD_Puts(sdCardText); break; default: break; } _INT3IP = 1; // Re-enable INT3 }
void display(uint8_t i, uint8_t co) { LCD_Clear(); LCD_SetCursor(0, 0); LCD_Puts("Charge Station 5"); LCD_SetCursor(0, 1); if (auto_cut_ON[print_port]) { switch (i) { case 0: LCD_Puts("Right"); break; case 1: LCD_Puts("Center"); break; case 2: LCD_Puts("Left"); break; } } else { switch (i) { case 0: LCD_Puts("RIGHT"); break; case 1: LCD_Puts("CENTER"); break; case 2: LCD_Puts("LEFT"); break; } } switch (co) { case 0://Port Name, x.xxxA LCD_SetCursor(8, 1); LCD_Putc((v[i] % 10000) / 1000 + '0'); LCD_Putc('.'); LCD_Putc((v[i] % 1000) / 100 + '0'); LCD_Putc((v[i] % 100) / 10 + '0'); LCD_Putc((v[i] % 10) / 1 + '0'); LCD_Putc('A'); break; case 1://Port Name, xxxxxmAh LCD_SetCursor(7, 1); LCD_Putc((s[i] % 1000000) / 100000 + '0'); LCD_Putc((s[i] % 100000) / 10000 + '0'); LCD_Putc((s[i] % 10000) / 1000 + '0'); LCD_Putc((s[i] % 1000) / 100 + '0'); LCD_Putc((s[i] % 100) / 10 + '0'); LCD_Putc((s[i] % 10) / 1 + '0'); LCD_Puts("mAh"); break; case 2://Port Name, Reset? LCD_SetCursor(8, 1); LCD_Puts("Reset?"); break; case 3://Port Name, Reseted LCD_SetCursor(8, 1); LCD_Puts("Reseted"); break; case 4://Port Name, alwaysON LCD_SetCursor(7, 1); LCD_Puts("Always ON"); break; case 5://Port Name, alwaysOFF LCD_SetCursor(7, 1); LCD_Puts("Auto Stop"); break; } }
/*====================================================== * メインルーチン * *======================================================*/ int main() { char LCD_LINE[17] = ""; /* Init and start sequencing SAR ADC */ ADC_SAR_Seq_Start(); ADC_SAR_Seq_StartConvert(); /* Init and start I2C master */ I2CM_Start(); CyDelay(500); CyGlobalIntEnable; /* Start I2C LCD */ // LCDをRESET LCD_RESET_Write(0u); CyDelay(1); LCD_RESET_Write(1u); CyDelay(10); LCD_Init(32); LCD_Clear(); LCD_Puts("Pyun2Controller2"); LCD_SetPos(0, 1); LCD_Puts("Demonstration"); CyDelay(500); for(;;) { pollingADC(); pollingSW(); #ifdef _ADC_8BIT sprintf(LCD_LINE, "%02x %02x %02x : %02x %02x", adcResult[ADC_CH_POT1_N] >> 3, adcResult[ADC_CH_POT2_N] >> 3, adcResult[ADC_CH_POT3_N] >> 3, adcResult[ADC_CH_JOY1_N] >> 3, adcResult[ADC_CH_JOY2_N] >> 3 ); #else sprintf(LCD_LINE, "%03x%03x%03x:%03x%03x", adcResult[ADC_CH_POT1_N], adcResult[ADC_CH_POT2_N], adcResult[ADC_CH_POT3_N], adcResult[ADC_CH_JOY1_N], adcResult[ADC_CH_JOY2_N] ); #endif LCD_SetPos(0, 0); LCD_Puts(LCD_LINE); sprintf(LCD_LINE, "%s %s %s %s : %s %s ", buttonStatus.green ? "G" : "x", buttonStatus.yellow ? "Y" : "x", buttonStatus.red ? "R" : "x", buttonStatus.blue ? "B" : "x", buttonStatus.black ? "K" : "x", buttonStatus.white ? "W" : "x" ); LCD_SetPos(0, 1); LCD_Puts(LCD_LINE); //CyDelay(1000); } }
/** * Clears a row of the display */ void LCD_ClearRow(LCD_RowTypeDef LCD_Row) { // print empty string - will be padded with spaces LCD_Puts("",LCD_Row); }