void LCD_Startup() { InitScibGpio(); scib_fifo_init(); // Init SCI-B // LCD_Reset(); LCD_Clear(); LCD_Backlight(30); Clock_start(LCD_CLOCK); LCD_S.init = 1; }
/** * @brief Example main entry point. * @par Parameters: * None * @retval * None */ void main(void) { /* Initialize SPI for LCD */ SPI_DeInit(); SPI_Init(SPI_FIRSTBIT_MSB, SPI_BAUDRATEPRESCALER_128, SPI_MODE_MASTER, SPI_CLOCKPOLARITY_HIGH, SPI_CLOCKPHASE_2EDGE, SPI_DATADIRECTION_1LINE_TX, SPI_NSS_SOFT, 0x07); SPI_Cmd(ENABLE); /* Configure GPIO used to drive the joystick JOYSTICK_UP --> PB6 JOYSTICK_DOWN --> PB7 JOYSTICK_LEFT --> PB4 */ GPIO_Init(GPIOB, GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7, GPIO_MODE_IN_FL_IT); EXTI_SetExtIntSensitivity(EXTI_PORT_GPIOB, EXTI_SENSITIVITY_FALL_LOW); enableInterrupts(); /* Initialize LCD */ LCD_Init(); /* Clear LCD lines */ LCD_Clear(); LCD_Backlight(ENABLE); LCD_PrintString(LCD_LINE1, ENABLE, DISABLE, "Clock Selection"); LCD_PrintString(LCD_LINE2, ENABLE, DISABLE, " Use joystick"); CLK_DeInit(); CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1); /* Output Fcpu on CLK_CCO pin */ CLK_CCOConfig(CLK_OUTPUT_MASTER); while (1) { } }
int main(void) { // start page t_page page = DataPage; // Init Basic_Init(); LCD_Backlight(_on); // Input struct InputHandler input_handler; struct Modem modem; InputHandler_init(&input_handler); Modem_init(&modem); while(1) { Watchdog_Restart(); PORT_Bootloader(); Modem_Check(page, &modem); // Debug Code if(DEBUG) { PORT_Debug(); } //------------------------------------------------GreatLinker switch(page) { case AutoPage: page = LCD_AutoPage(page); break; case ManualPage: page = LCD_ManualPage(page); break; case SetupPage: page = LCD_SetupPage(page); break; case DataPage: page = LCD_DataPage(page); break; //----------------------------------------------Pin-Pages case PinManual: page = LCD_PinPage(page); break; case PinSetup: page = LCD_PinPage(page); break; //----------------------------------------------Auto-Pages case AutoZone: case AutoSetDown: case AutoPumpOff: case AutoMud: case AutoCirc: case AutoCircOff: case AutoAir: case AutoAirOff: page = LCD_AutoPage(page); PORT_RunTime(&input_handler); break; //----------------------------------------------Manual-Pages case ManualMain: case ManualCirc: case ManualCircOff: case ManualAir: case ManualSetDown: case ManualPumpOff: case ManualPumpOff_On: case ManualMud: case ManualCompressor: case ManualPhosphor: case ManualInflowPump: page = LCD_ManualPage(page); break; //----------------------------------------------Manual-Pages case SetupMain: case SetupCirculate: case SetupAir: case SetupSetDown: case SetupPumpOff: case SetupMud: case SetupCompressor: case SetupPhosphor: case SetupInflowPump: case SetupCal: case SetupCalPressure: case SetupAlarm: case SetupWatch: case SetupZone: page = LCD_SetupPage(page); break; //----------------------------------------------Data-Pages case DataMain: case DataAuto: case DataManual: case DataSetup: case DataSonic: case DataSonicAuto: case DataSonicBoot: case DataSonicBootR: case DataSonicBootW: page = LCD_DataPage(page); break; default: page = AutoPage; break; } } }
void main(void){ unsigned char i,cmd, param[9]; //unsigned char t[]={"Hello World"}; init(); //setup the crystal, pins usbbufflush(); //setup the USB byte buffer delayMS(10); HD44780_Reset();//setup the LCD HD44780_Init(); USBDeviceInit();//setup usb while(1){ USBDeviceTasks(); if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1)) continue; usbbufservice();//load any USB data into byte buffer cmd=waitforbyte();//wait for a byte from USB if(cmd!=MATRIX_ORBITAL_COMMAND){//assume text, if 254 then enter command mode LCD_WriteChar(cmd); //not a command, just write it to the display }else{//previous byte was 254, now get actual command switch(waitforbyte()){//switch on the command case BACKLIGHT_ON: //1 parameter (minutes 00=forever) param[0]=waitforbyte(); LCD_Backlight(1);//turn it on, we ignore the parameter break; case BACKLIGHT_OFF: LCD_Backlight(0);//backlight off break; case CLEAR: LCD_Clear(); break; case HOME: LCD_Home(); break; case POSITION: //2 parameters (col, row) param[0]=waitforbyte(); param[1]=waitforbyte(); cmd=( ((param[1]-1)*20) + param[0] ); //convert to 20x4 layout (used defined lines, add rows...) LCD_CursorPosition(cmd); break; case UNDERLINE_CURSER_ON: LCD_UnderlineCursor(1); break; case UNDERLINE_CURSER_OFF: LCD_UnderlineCursor(0); break; case BLOCK_CURSER_ON: LCD_BlinkCursor(1); break; case BLOCK_CURSER_OFF: LCD_BlinkCursor(0); break; case BACKLIGHT_BRIGHTNESS://1 parameter (brightness) param[0]=waitforbyte(); break; case CUSTOM_CHARACTER: //9 parameters (character #, 8 byte bitmap) LCD_WriteCGRAM(waitforbyte());//write character address for(i=1; i<9; i++){ LCD_WriteRAM(waitforbyte()); //send 8 bitmap bytes } break; default: //error break; } } CDCTxService(); } }//end main
/** * \fn HMI_Setup(const THMISetup * const aHMISetup) * \brief Setup HMI system. * \param aHMIContext A pointer of HMI configuration structure * \return TRUE if HMI is set properly or FALSE when failed */ BOOL HMI_Setup(const THMISetup * const aHMISetup) { UINT16 i = 0, j = 0; #ifndef NO_INTERRUPT TTimerSetup timerCh6; timerCh6.outputCompare = bTRUE; timerCh6.outputAction = TIMER_OUTPUT_DISCONNECT; timerCh6.inputDetection = TIMER_INPUT_OFF; timerCh6.toggleOnOverflow = bFALSE; timerCh6.interruptEnable = bFALSE; timerCh6.pulseAccumulator = bFALSE; timerCh6.routine = &HMIRoutine; #endif if (aHMISetup) { if (LCD_Setup()) { HMIContext.renderMode = aHMISetup->renderMode; //HMIContext.idlePanelId = aHMISetup->idlePanelId; HMIContext.screenFrameBufferPtr = &HMIFrameBuffer[0]; HMIContext.renderFrameBufferPtr = &HMIFrameBuffer[1]; for (j = 0; j < aHMISetup->frameTemplate.height; ++j) { for (i = 0; i < aHMISetup->frameTemplate.width; ++i) { HMIContext.frameTemplate.data[j][i] = aHMISetup->frameTemplate.data[j][i]; } } HMIContext.frameTemplate.width = aHMISetup->frameTemplate.width; HMIContext.frameTemplate.height = aHMISetup->frameTemplate.height; HMIContext.focusedMenuItemId = 0xFF; HMIContext.selectedMenuItemId = 0xFF; HMIContext.idlePanelId = aHMISetup->idlePanelId; HMIContext.idleTimeCount = 0; HMIContext.maxIdleTimeCount = aHMISetup->maxIdleTimeCount; HMIContext.parentPanelId = 0; HMIContext.currentPanelId = 0; HMIContext.previousPanelId = 0; HMIContext.popupPtr = (THMIPopup*)0x00; HMIContext.maxPopupTimeCount = 10; HMIContext.popupTimeCount = 0; HMIContext.oldHours = 0; HMIContext.oldMinutes = 0; HMIContext.oldSeconds = 0; HMIContext.hours = 0; HMIContext.minutes = 0; HMIContext.seconds = 0; HMIContext.backlight = aHMISetup->backlight; HMIContext.backlightChangedCallback = aHMISetup->backlightChangedCallback; HMIContext.contrast = aHMISetup->contrast; HMIContext.contrastChangedCallback = aHMISetup->contrastChangedCallback; #ifndef NO_INTERRUPT HMIRoutinePeriod = (UINT16)(48000); // 2ms Timer_Init(TIMER_Ch6, &timerCh6); Timer_Set(TIMER_Ch6, HMIRoutinePeriod); Timer_AttachRoutine(TIMER_Ch6, &HMIRoutine); Timer_Enable(TIMER_Ch6, bTRUE); #endif DDRK = DDRK & (DDRK_BIT0_MASK | DDRK_BIT1_MASK); UNUSED(LCD_Backlight(aHMISetup->backlight)); UNUSED(LCD_SetContrast((UINT8)aHMISetup->contrast)); return bTRUE; } else { #ifndef NO_DEBUG DEBUG(__LINE__, ERR_LCD_SETUP); #endif } } else { DEBUG(__LINE__, ERR_INVALID_POINTER); } return bFALSE; }
/** * \fn BOOL HMIPopupProcessRoutine(void) * \brief Default HMI popup process routine * \return TRUE if popup related process has been done or FALSE when bypassed */ BOOL HMIPopupProcessRoutine(void) { static BOOL pressedKey2 = bFALSE; /* TODO: connect variables to ModConHMIBacklight and ModConHMIContrast */ BOOL showBacklight = bFALSE, showContrast = bFALSE; if (HMI_KEY5) { if (HMI_KEY2 && !pressedKey2) { HMIContext.backlight = !HMIContext.backlight; showBacklight = bTRUE; } else if (HMI_KEY3) { if (HMIContext.contrast > 0) { --HMIContext.contrast; } showContrast = bTRUE; } else if (HMI_KEY4) { if (HMIContext.contrast < 63) { ++HMIContext.contrast; } showContrast = bTRUE; } } pressedKey2 = HMI_KEY2; if (showBacklight) { if (HMIContext.backlight) { CopyBytes(&HMI_BACKLIGHT_POPUP.text[2][6], (UINT8*)" ON", 3); } else { CopyBytes(&HMI_BACKLIGHT_POPUP.text[2][6], (UINT8*)"OFF", 3); } LCD_Backlight(HMIContext.backlight); HMI_ShowPopup(&HMI_BACKLIGHT_POPUP); if (HMIContext.backlightChangedCallback) { HMIContext.backlightChangedCallback(HMIContext.backlight); } return bTRUE; } else if (showContrast) { HMI_CONTRAST_POPUP.text[2][6] = HMIContext.contrast / 10 + '0'; HMI_CONTRAST_POPUP.text[2][7] = HMIContext.contrast % 10 + '0'; UNUSED(LCD_SetContrast(HMIContext.contrast)); HMI_ShowPopup(&HMI_CONTRAST_POPUP); if (HMIContext.contrastChangedCallback) { HMIContext.contrastChangedCallback(HMIContext.contrast); } return bTRUE; } return bFALSE; }
/** * \fn void HMI_SetBacklight(BOOL backlight) * \brief Sets the display backlight on or off * \param backlight whether the backlight is on or off */ void HMI_SetBacklight(BOOL backlight) { UNUSED(LCD_Backlight(backlight)); }