int main (int argc, char *argv []) { lcd_init(); SetChrMode(); lcd_text("hello world!"); SetCmdMode(); lcd_gotoxy(1,2); SetChrMode(); lcd_text("Luis"); return 0 ; }
static void brew_run_step() { g_state.step_start_tick = xTaskGetTickCount(); g_state.step_runtime = 0; // iterate will update this lcd_lock(); lcd_fill(0, 0, LCD_W, CRUMB_H, 0x0); lcd_background(0x0); lcd_text(0, 0, "Brewbot:Brewing"); lcd_fill(0, CRUMB_H - 2, LCD_W, 2, 0xFFFF); lcd_fill(0, CRUMB_H, LCD_W, LCD_H - CRUMB_H, COL_BG_NORM); lcd_fill(0, LCD_H - 1 * HH - 1, LCD_W / 2, 1, 0xFFFF); lcd_fill(LCD_W / 2, LCD_H - 1 * HH - 1, 1, HH, 0xFFFF); button_paint(brew_buttons); if (g_steps[g_state.step].buttons) button_paint(g_steps[g_state.step].buttons); lcd_background(COL_BG_NORM); lcd_printf(17, 0, 20, "%d.%s", g_state.step, g_steps[g_state.step].name); lcd_release(); log_brew(&g_state.log_file, "%.2d:%.2d Run step %d.%s\n", g_state.total_runtime / 60, g_state.total_runtime % 60, g_state.step, g_steps[g_state.step].name); g_steps[g_state.step].method(1); }
void brew_resume(int init) { if (init) { g_state.in_alarm = 0; lcd_lock(); lcd_fill(0, 0, LCD_W, CRUMB_H, 0x0); lcd_text(0, 0, "Brewbot:Resume at step"); lcd_fill(0, CRUMB_H - 2, LCD_W, 2, 0xFFFF); lcd_fill(0, CRUMB_H, LCD_W, LCD_H - CRUMB_H - 2 * HH, COL_BG_NORM); lcd_fill(0, LCD_H - 2 * HH - 2, LCD_W, 1, 0xFFFF); lcd_fill(0, LCD_H - 1 * HH - 1, LCD_W, 1, 0xFFFF); lcd_fill(LCD_W / 2, LCD_H - 2 * HH - 1, 1, 2 * HH, 0xFFFF); button_paint(resume_buttons); lcd_background(COL_BG_NORM); lcd_printf(10, 4, 30, "%d. %s", g_state.step + 1, brew_step_name(g_state.step)); lcd_release(); } else { log_brew(&g_state.log_file, "%.2d:%.2d Brew stopped\n", g_state.total_runtime / 60, g_state.total_runtime % 60); brewTaskStop(&brew_task); } }
int main(void){ lcdinit(); goto_xy(0,0); lcd_text("hello"); //lcd_text(); //lcd_text(); //lcd_int(10); while(1); return 0; }
void settings_display(int init) { if (init) { lcd_text(0, 0, " Settings"); settings_display_menu(); } else { settings_save(); } }
static void menu_update(void) { start_time = xTaskGetTickCount(); unsigned char ii; uint16_t bgCol = COL_BG_NORM; lcd_lock(); lcd_background(0); // clear menu bg lcd_fill(0, CRUMB_H, LCD_W, LCD_H - CRUMB_H, bgCol); // draw the crumbs char crumbs[90] = "Brewbot"; for (ii = 1; ii <= g_index; ii++) { strcat(crumbs, ":"); strcat(crumbs, g_menu[ii-1][g_crumbs[ii-1]].text); } lcd_fill(0, 0, LCD_W, CRUMB_H, 0x0); lcd_text(0, 0, crumbs); lcd_fill(0, CRUMB_H - 2, LCD_W, 2, 0xFFFF); // how big is the menu? g_entries = 0; for (ii = 0; g_menu[g_index][ii].text; ii++) { g_entries++; } // if above a certain size draw in two columns if (g_entries > 4) { menu_two_column(); } else { g_rows = g_entries; g_rowh = (240 - CRUMB_H) / g_entries; for (ii = 0; g_menu[g_index][ii].text; ii++) { menu_paint_cell(ii); if (ii != g_entries - 1) lcd_fill(0, CRUMB_H + (ii +1) * (g_rowh) - 1, LCD_W, 1, 0xFFFF); } } lcd_printf(30, 0, 10, "%dms", (xTaskGetTickCount() - start_time)); lcd_release(); }
static void settings_display_menu() { int ii; for (ii = 0; ii < SETTINGS_DISPLAY_SIZE && settings_display_list[ii + settings_offset].fmt != NULL; ii++) { struct settings_display *disp = &settings_display_list[ii + settings_offset]; if (disp->type == FLOAT) { lcd_printf(0, 1 + ii, 19, disp->fmt, *((float *)disp->value)); } else if (disp->type == UINT8) { lcd_printf(0, 1 + ii, 19, disp->fmt, *((uint8_t *)disp->value)); } if (ii + settings_offset == settings_cursor) { lcd_text(0, 1 + ii, ">"); } } }
void lcd_int(unsigned int value) { char buf[8]; lcd_text( itoa(value, buf, 10) ); }
int main(int argc, char *argv[]) { //Set our Logging Mask and open the Log setlogmask(LOG_UPTO(LOG_ERR)); openlog(DAEMON_NAME, LOG_CONS | LOG_NDELAY | LOG_PERROR | LOG_PID, LOG_USER); syslog(LOG_INFO, "Entering Daemon"); pid_t pid, sid; //Fork the Parent Process pid = fork(); if (pid < 0) { exit(EXIT_FAILURE); } //We got a good pid, Close the Parent Process if (pid > 0) { exit(EXIT_SUCCESS); } //Change File Mask umask(0); //Create a new Signature Id for our child sid = setsid(); if (sid < 0) { exit(EXIT_FAILURE); } //Change Directory //If we cant find the directory we exit with failure. if ((chdir("/")) < 0) { exit(EXIT_FAILURE); } // Ensure only one copy char *pidfile = PIDFILE; int pidFilehandle = open(pidfile, O_RDWR|O_CREAT, 0600); if (pidFilehandle == -1 ) { // Couldn't open lock file syslog(LOG_ERR, "Could not open PID lock file %s, exiting", pidfile); exit(EXIT_FAILURE); } // Try to lock file if (lockf(pidFilehandle,F_TLOCK,0) == -1) { // Couldn't get lock on lock file syslog(LOG_ERR, "Could not lock PID lock file %s, exiting", pidfile); exit(EXIT_FAILURE); } // Get and format PID char str[10]; sprintf(str,"%d\n",getpid()); // write pid to lockfile write(pidFilehandle, str, strlen(str)); syslog(LOG_INFO, "created pid file %s with content %s", pidfile, str); //Close Standard File Descriptors close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); // Main code mraa_init(); mraa_gpio_context gpio[6]; char l1[16] = "LCD Daemon"; char l2[16] = " Started "; char T[5], H[5]; int numReads = 0; time_t now = time(NULL); struct tm *t = localtime(&now); lcd_init(gpio); lcd_text(gpio, l1, 1); lcd_text(gpio, l2, 2); sleep(1); while(1) { // Read LOGFILE to retrieve Temp and Humidity FILE *f = fopen(LOGFILE, "r"); if (f == NULL) return(1); numReads = fscanf(f, "%s", T); numReads += fscanf(f, "%s", H); fclose(f); if(numReads > 1) { sprintf(l1, " %sC %s%%", T, H); lcd_text(gpio, l1, 1); } // Grab and display the date and time on the second line time(&now); t = localtime(&now); strftime(l2, sizeof(l2), " %d.%m.%y %H:%M", t); lcd_text(gpio, l2, 2); // Sleep for a minute sleep(58); } lcd_close(gpio); return MRAA_SUCCESS; }
/** * Program pooling a directory, and doing a scheduling. **/ int main (int argc, char** argv) { initPins(); adc_init(); lcd_init(); /** The status does not exist at the launch of the schduler prgram*/ clearFile(); int pid=readPid(); stopIfPidExists(pid); writePid(); SetChrMode(); int nbSecond; int remainingSeconds; uchar intensity; uchar tmpintensity; int i; int valueInFile; time_t whenItsComplete ; char timestr[7]; pinMode (RELAY_IN, OUTPUT); // Permanent loop checking file. int cycle=0; while(1){ valueInFile=getCoundownValue(); #ifndef PROD printf("pause:%d,valueInFile:%d\n",pauseSt,valueInFile); #endif if(valueInFile>=0){ nbSecond=valueInFile; // The countdown whenItsComplete = time(NULL)+nbSecond; remainingSeconds=whenItsComplete-time(NULL); } else{remainingSeconds=-1;} #ifndef PROD printf("nbsecond:%d\n",nbSecond); #endif do { /** * Do a regular reset of the LCD **/ if(cycle%500==0){ lcd_init(); } else if(cycle%60==0){ resetLcd(); } /** * Write the remaining seconds **/ if(cycle%60==0){ writeRemaining(remainingSeconds); } /** * Increment only if not in pause (Cycle increments will be at the end of the cycle loop. **/ updateStandbyStatus(); cycle++; if(remainingSeconds>-1){ if(pauseSt==IS_RUNNING){ remainingSeconds=whenItsComplete-time(NULL); }else{ whenItsComplete=remainingSeconds+time(NULL); } openRelay(); if(lastImmobileState==0||(time(NULL)-lastImmobileState)<NBSECONDBEFORECREENSHUTDOWN){ digitalWrite (TRANSISTOR, LOW); } else{ digitalWrite (TRANSISTOR, HIGH); } int seconds=remainingSeconds%60; int hours=remainingSeconds/3600; int minutes=remainingSeconds/60%60; sprintf(timestr,"%02d:%02d:%02d",hours,minutes,seconds); goHome(); lcd_text(timestr); #ifndef PROD printf("%s\n",timestr); #endif sleep(1); } /** * Block measuring intensity */ if(cycle%20==0){ intensity=get_ADC_Result(); #ifndef PROD printf("Intensite: %d\n",intensity); #endif } #ifndef PROD printf("Remaining seconds %d,cycle=%d\n",remainingSeconds,cycle); #endif } while ( remainingSeconds>0&& !isFilePresent()); #ifndef PROD // printf("Sortie boucle décompte\n"); #endif /** * Every 10 ccyle there is a full reset of the screen. Otherwise it is light reset. **/ if(cycle%100==0){ lcd_init(); } nbSecond=0; /** * **/ if(valueInFile==NO_FILE){ goHome(); closeRelay(); digitalWrite (TRANSISTOR, HIGH); lcd_text("Expire " ); #ifndef PROD printf("Expire\n"); #endif } else if(valueInFile==TV_ON){ goHome(); openRelay(); digitalWrite (TRANSISTOR, LOW); lcd_text("Tele on " ); } else if(valueInFile==TV_OFF){ goHome(); digitalWrite (TRANSISTOR, HIGH); closeRelay(); lcd_text("Tele off " ); } sleep(3); } }
void cal_task( void * data) { // initialize LCD lcd_clear_all(); lcd_init(); lcd_led_power(1); // draw splash screen lcd_text(32,10,3,"NFC",0); lcd_text(12,40,1,"ipTronix Arrow NXP",0); lcd_update(0,63); // initialize pll Si5351_Initialize(); // prepare new screen during splash wait lcd_clear_all(); lcd_vert_line(10,63,64); vTaskDelay(500); // application main loop for (;;) { int i; int max = 0; int maxval = 0; for (i=0;i<128;i++) { Si5351_OutputFrequency((9560000+i*8000000/128)*25/24); lcd_update(0,63); vTaskDelay(1); samples[i] = ADCRead(3); if (i!=64) lcd_clear_area(i,10,i,63); lcd_vert_line(63-samples[i]*51/1023,63,i); if (maxval<samples[i]) { maxval = samples[i]; max = i; } if (GPIOGetPinValue( PIN_ISP ) == 0) { lcd_clear_all(); lcd_text(52,26,2,"ISP",0); lcd_update(0,63); NVIC_SystemReset(); } if (GPIOGetPinValue( PIN_CAL_DET ) == 0) { NVIC_SystemReset(); } } char str[20]; float freq= 9.56+(float)max*8/128; sprintf(str,"fmax = %2d.%03d MHz",(int)freq,((int)(freq*1000))%1000); lcd_text(0, 0 , 0, str, 0); lcd_update(0,63); vTaskDelay(1500); lcd_clear_all(); lcd_vert_line(10,63,64); } }
void ui_task( void * data) { int i; portBASE_TYPE res; int count = 10; char acTempStr[20]; uint8_t acTemp[2]; uint8_t bMosfetEnabled = 0; // init LCD; lcd_clear_all(); lcd_init(); lcd_led_power(1); //lcd_test(0); lcd_text(32,10,3,"NFC",0); lcd_text(12,40,1,"ipTronix Arrow NXP",0); lcd_update(0,63); lcd_clear_all(); vTaskDelay(1500); lcd_clear_all(); for (;;) { KEY_EVENT_t key; char str[30]; lcd_text(12,10,1,"Please approach card",0); lcd_update(0,63); do { res = xQueueReceive(xUIQueue,&taginfo,/*portMAX_DELAY*/20); key=CAP_KEY_GetEvent(); count++; if ((count >= 3) && (res!= pdPASS)) { count = 0; I2CRead(0x90,0,&acTemp[0],2); sprintf(acTempStr,"Temperature %d",acTemp[0]); lcd_text(12,27,1,acTempStr,0); sprintf(acTempStr,"Keys %d",keystate); lcd_text(28,46,2,acTempStr,0); lcd_update(0,63); } if (bMosfetEnabled) { bMosfetEnabled = 0; GPIOSetBitValue(PIN_MOSFET,0); } else { bMosfetEnabled = 1; GPIOSetBitValue(PIN_MOSFET,1); } if (GPIOGetPinValue( PIN_ISP ) == 0) { lcd_clear_all(); lcd_text(52,26,2,"ISP",0); lcd_update(0,63); NVIC_SystemReset(); } if (GPIOGetPinValue( PIN_CAL_DET )) { NVIC_SystemReset(); } } while (res!= pdPASS) ; if (res == pdPASS) { lcd_clear_all(); sprintf(str, "UID "); for (i=0;i<taginfo.szUidLen;i++) { sprintf(&str[4+i*2],"%02X",taginfo.abtUid[i]); } lcd_text(0,0,1,str,0); sprintf(str,"NDEF Len %d",taginfo.msgLen); lcd_text(0,12,1,str,0); snprintf(str,30,"MSG %s",taginfo.msg); lcd_text(0,24,1,str,0); lcd_update(0,63); vTaskDelay(1500); lcd_clear_all(); count = 10; } lcd_update(0,63); } }
void ui_task( void * data) { portBASE_TYPE res; m_eMode = mdAUTHENTICATE; // init LCD; lcd_clear_all(); lcd_init(); lcd_led_power(1); //lcd_test(0); lcd_text(32,10,3,"NFC",0); lcd_text(12,40,1,"ipTronix Arrow NXP",0); lcd_update(0,63); lcd_clear_all(); vTaskDelay(1500); for (;;) { char str[30]; lcd_clear_all(); lcd_text(32,0,1,"Authentication",0); lcd_text(32,20,2,"Scan card",0); switch (m_eMode) { case mdAUTHENTICATE: lcd_text(10,40,2,"AUTHENTICATE",1); break; case mdAUTHORIZE: lcd_text(22,40,2,"AUTHORIZE",1); break; case mdDENY: lcd_text(42,40,2,"DENY",1); break; } lcd_update(0,63); do { key=CAP_KEY_GetEvent(); res = xQueueReceive(xUIQueue,&payload,100); if (GPIOGetPinValue( PIN_ISP ) == 0) { lcd_clear_all(); lcd_text(52,26,2,"ISP",0); lcd_update(0,63); NVIC_SystemReset(); } } while ((key==keNONE) && (res!= pdPASS)); if (key==keK3_PRESS || key==keK3_REPEAT) { if (m_eMode<mdDENY) m_eMode++; else m_eMode=mdAUTHENTICATE; } else if (key==keK1_PRESS || key==keK1_REPEAT) { if (m_eMode>mdAUTHENTICATE) m_eMode--; else m_eMode = mdDENY; } key=keNONE; if (res==pdPASS) { lcd_clear_all(); snprintf(str, sizeof(payload.name),"Name %s", payload.name); lcd_text(0,20,2,str,0); sprintf(str,"Access %08X",payload.access_rights); lcd_text(0,40,2,str,0); lcd_update(0,63); if (payload.access_rights==0xffffffff) GPIOSetBitValue(PIN_MOSFET,1); vTaskDelay(1500); GPIOSetBitValue(PIN_MOSFET,0); } } }