void execute_state_entry(state_t state) { switch(state) { case READY_STATE: LCD_clear(); LCD_putsub("Wez go \ndo buzi"); break; case DRINKING_STATE: led_on(); LCD_clear(); start_time_measurement(); break; case VERIFICATION_STATE: verified_time = *get_current_time(); LCD_display_time(&verified_time); verification_state_duration = 0u; break; case DISPLAY_STATE: stop_time_measurement(); //led_on(); led_flashing_duration = 0u; //LCD_display_time(get_current_time()); // drinking time end display break; case ADC_STATE: LCD_clear(); break; } state_is_new = 0u; }
/******************************************************************* * Function: int waitButton(void) * Input Variables: none * Output Return: int * Overview: Use a comment block like this before functions ********************************************************************/ int WaitButton( void ) { BOOL btnState1, btnState2, btnState3;//local variables - button states //int rtnValue=0;//return the button value int rtnValue=0; LCD_clear(); if((ATopstat.state=SUBSYS_OPEN)) { // Get switch states. btnState1 = ATTINY_get_SW_state( ATTINY_SW3 ); btnState2 = ATTINY_get_SW_state( ATTINY_SW4 ); btnState3 = ATTINY_get_SW_state( ATTINY_SW5 ); //LCD_printf("btnStates: %d %d %d \n", btnState1, btnState2, btnState3); if( btnState1 == TRUE ) { LCD_printf( "SW1: Pushed\n"); // TMRSRVC_delay(500);//wait 1 s // Assume the LED subsystem opened successfully. LED_set_pattern( 0b00100000 );//turn the red LED on TMRSRVC_delay(500);//wait 2 seconds LED_clr_pattern( 0b01000000 );//turn the green LED off LED_clr_pattern( 0b00100000 );//turn the red LED off rtnValue=1; }//end if button 1 state open if( btnState2 == TRUE ) { LCD_printf( "SW2: Pushed\n"); // TMRSRVC_delay(500);//wait 1 s // Assume the LED subsystem opened successfully. LED_set_pattern( 0b01000000 );//turn the green LED on TMRSRVC_delay(500);//wait 2 seconds LED_clr_pattern( 0b01000000 );//turn the green LED off LED_clr_pattern( 0b00100000 );//turn the red LED off rtnValue=2; }//end if btn 2 open if ( btnState3 == TRUE ) { LCD_printf( "SW3: Pushed\n"); // TMRSRVC_delay(500);//wait 1 s // Assume the LED subsystem opened successfully. LED_set_pattern( 0b01000000 );//turn the green LED on LED_set_pattern( 0b00100000 );//turn the red LED on TMRSRVC_delay(500);//wait 2 seconds LED_clr_pattern( 0b01000000 );//turn the green LED off LED_clr_pattern( 0b00100000 );//turn the red LED off rtnValue=3; }//end if btn 3 open LCD_clear(); return rtnValue; }//end AT while }//end the WaitButton() function
void SERIAL_readDataBlock(uint8_t * data, uint16_t dataLength){ uint8_t currentArray[8]; uint8_t * current = ¤tArray; int progress = 0; int oldprogress = 0; if(current == NULL){ SERIAL_wait("null pointer"); } int i; LCD_clear(); LCD_write_int("%d", progress); for(i = 0; i < dataLength; i+=8){ oldprogress = progress; progress = (int)(100*((float)i/dataLength)); if(oldprogress != progress){ LCD_clear(); LCD_write_int("%d", progress); } SERIAL_read8Bytes(current); int j; for(j = i; j < i+8; j++){ data[j] = current[j%8]; } } data[dataLength] = '\0'; }
//============================================================================= int main(void) { LIGHT_init(); LCD_init(); LIGHT_on(); LCD_clear(); BEEP_init(); RTC_init(); RTOS_init(); RC5_Init(); RC5_Reset(); ENC_init(); KBD_init(); bmp180Init(); dht22Init(); rda5807Init(); rda5807PowerOn(); rda5807SetMute(1); ds18x20SearchDevices(); LCD_goto(0, 0); LCD_puts("POGODNAY STATION"); LCD_goto(0, 1); LCD_puts(" VERSION 1.0 "); _delay_ms(1000); LCD_clear(); LCD_load_bignum(); ds18x20Process(); if (bmp180HaveSensor()) bmp180Convert(); dht22Read(); #if (DEBUG == 1) if ((BUT_1_PINX & (1<<(BUT_1_PIN))) == 0) { _delay_ms(100); if ((BUT_1_PINX & (1<<(BUT_1_PIN))) == 0) { RTOS_setTask(EVENT_SET_STATE_OPTION, 0, 0); BEEP_beep(); while (((BUT_1_PINX & (1<<(BUT_1_PIN))) == 0)) { } BEEP_beep(); } } #else RTOS_setTask(EVENT_SET_STATE_OPTION, 0, 0); BEEP_beep(); #endif RTOS_setTaskFunc(set_blink, 0, 1000); // моргание RTOS_setTaskFunc(KBD_scan, 0, 5); // запускаем опрос кнопок RTOS_setTaskFunc(ENC_poll, 0, 1); // запускаем опрос енкодера RTOS_setTaskFunc(RC5_scan, 0, 5); // запускаем опрос RC5 RTOS_setTask(EVENT_SET_SHOW, 0, 0); // запуск шоу sei(); // Разрешили прерывания while(1) { RTOS_dispatchTask(); // Вызываем диспетчер в цикле. } }
void main() { uchar *p; p="by Jasper"; Init(); IsReset=0; IsReset=eeprom_read(100); if(!IsReset) //首次进入输入密码和显示欢迎界面 { Confirm(); LCD_clear(); delay_ms(200); LCD_write_str(5,0,"welcome"); while(*p) { LCD_write_char(i,1,*p); p++; i++; delay_ms(100); } } LCD_clear(); //正式进入系统 LCD_write_str(0,0,"1bell2led3motor"); LCD_write_str(0,1,"4fix_password"); while(1) { eeprom_write(100,0); if(select=='1') //蜂鸣器模式 { LCD_clear(); LCD_write_str(0,0,"buzz..send * or"); LCD_write_str(0,1,"shutdown to exit"); Bell(); } if(select=='2') LED(); //led模式 if(select=='3') Motor(); //电机模式 if(select=='4') Write_password(); //修改密码模式 } }
void Menu_Generic(PVOID course, pOption options[], U8 sizeOf){ pPercurso percurso = (pPercurso)course; U32 currentTime=rtc_getCurrentTime(); U8 elapsedTime=0; U8 idx = 0,bidx = -1; KB_Key key; while(1){ if (bidx != idx){ LCD_clear(); LCD_writeLine(0,"Press OK or Next"); LCD_writeLine(1,options[idx].text); bidx = idx; } if (keyboard_hasKey()){ currentTime=rtc_getCurrentTime(); switch(key = keyboard_getBitMap()){ case OK: options[idx].function(percurso); break; case RIGHT: case DOWN: idx = __FX0(idx,1,sizeOf); break; case LEFT: case UP: idx = __FX0(idx,-1,sizeOf); break; case CANCEL: LCD_clear(); return; default: //do nothing break; } elapsedTime=0; }else{ //no key elapsedTime ++; if(elapsedTime >__WAIT_PERIOD_30_Seconds__){ LCD_clear(); return; } timer_sleep_miliseconds(pTIMER1, 200); } WD_reset(); } }
#if __NOT_IMPLEMENTED_YET void DBG_debug_try(void) { uint8_t i_ultra = 0; INIT_ultraPredef(i_ultra ,0); uint8_t ilcd = 0; S_dev_lcd* lcd_dev = &(predef_lcds[ilcd]); S_sensor_ultra* ultra = &(predef_ultras[i_ultra]); ULTRA_signalSend(ultra); while(1) { ultra->dist = 0; while( !gpio_get(ultra->rxport,ultra->rxpin) ) { __asm__("nop"); } while( gpio_get(ultra->rxport,ultra->rxpin) ) { (ultra->dist)++; } //u30+4;u10+1 ultra->dist *= 1.1;//1.111;//1.33333333;//(1 + 4.0/30); LCD_clear(r->lcd); fprintf(flcd, "dist[cm]=%.2f", ultra->dist/100);//ULTRA_getDist(i_ultra)); mswait(500); }
/*-------------------------------------------------------------------------------------------------- Name : LCD_init Description : LCD controller initialization. Argument(s) : None. Return value : None. --------------------------------------------------------------------------------------------------*/ void LCD_init ( void ) { DDRB |= (1<<PB0) | (1<<PB1) | (1<<PB2); CLEAR_RST_PIN; //reset LCD _delay_ms(2); CLEAR_SCE_PIN; //Enable LCD _delay_ms(2); SET_RST_PIN; SET_SCE_PIN; //disable LCD LCD_writeCommand( 0x21 ); // LCD Extended Commands. LCD_writeCommand( 0x80 | 0x30); // Set LCD Vop (Contrast). LCD_writeCommand( 0x04 ); // Set Temp coefficent. LCD_writeCommand( 0x13 ); // LCD bias mode 1:48. LCD_writeCommand( 0x20 ); // LCD Standard Commands, Horizontal addressing mode. LCD_writeCommand( 0x09 ); // all display segments on _delay_ms(500); LCD_writeCommand( 0x0c ); // LCD in normal mode. LCD_clear(); _delay_ms(500); }
void LCD_init(void) { LCDGPIO_init();//所需io初始化 LCD_RST_L; // 产生一个让LCD复位的低电平脉冲 delay_1us(); // DELAY_MS(1) ; LCD_RST_H; LCD_CE_L; // 关闭LCD delay_1us(); // DELAY_MS(1) ; LCD_CE_H; // 使能LCD delay_1us(); // DELAY_MS(1) ; LCD_write_byte(0x21, 0); // 使用扩展命令设置LCD模式 LCD_write_byte(0xc8, 0); // 设置液晶偏置电压 LCD_write_byte(0x06, 0); // 温度校正 LCD_write_byte(0x13, 0); // 1:48 LCD_write_byte(0x20, 0); // 使用基本命令,V=0,水平寻址 LCD_clear(); // 清屏 LCD_write_byte(0x0c, 0); // 设定显示模式,正常显示 LCD_CE_L; // 关闭LCD }
void setup_LCD() { uint8_t i; // wait 50ms for LCD to come up Delay(50); // reset pins to all 0 send_LCD(0); DelayUS(4500); for(i = 0; i < 3; i++) { // try three times to set LCD into a known state (re-sync half-byte stream) // start by setting 8 bit mode send_halfbyte(LCD_FUNCTIONSET|LCD_8BITMODE); DelayUS(4500); // wait a minimum of 4.1ms } // set in 4 bit mode send_halfbyte(LCD_FUNCTIONSET|LCD_4BITMODE); // set # of lines, font size, etc send_byte(LCD_FUNCTIONSET|LCD_2LINE|LCD_4BITMODE|LCD_5x8DOTS, 0); // TODO: does this need a modifier? // turn on display send_byte(LCD_BACKLIGHT|LCD_DISPLAYON|LCD_CURSOROFF|LCD_BLINKOFF, 0); LCD_clear(); // left to right send_byte(LCD_ENTRYMODESET|LCD_ENTRYLEFT|LCD_ENTRYSHIFTDECREMENT, 0); LCD_home(); LCD_print_char('B'); }
void LCD4884::LCD_init(void) { CTick to; for (int i = 0; i < 6; i++) { lcd[i].output(NOT_OPEN); // set lcd I/F as output pins if ( i==SPI_SCK ) { lcd[i] = HIGH; } else { lcd[i] = LOW; } } lcd[LCD_RST] = LOW; to.delay(2); lcd[LCD_RST] = HIGH; lcd[SPI_CS] = LOW; to.delay(2); lcd[SPI_CS] = HIGH; to.delay(2); lcd[LCD_BL] = HIGH; LCD_write_byte(0x21, 0); LCD_write_byte(0xc0, 0); LCD_write_byte(0x06, 0); LCD_write_byte(0x13, 0); LCD_write_byte(0x20, 0); LCD_clear(); LCD_write_byte(0x0c, 0); // lcd[SPI_CS] = HIGH; }
void LCD_init(void) { _delay_ms(50); // 연결 핀을 출력으로 설정 if(MODE == 8) DDR_DATA |= 0xFF; else DDR_DATA |= 0xF0; DDR_CONTROL |= (1 << RS_PIN) | (1 << E_PIN); if(MODE == 8) LCD_write_command(COMMAND_8_BIT_MODE); // 8비트 모드 else{ LCD_write_command(0x02); // 4비트 모드 추가 명령 LCD_write_command(COMMAND_4_BIT_MODE); // 4비트 모드 } // display on/off control // 화면 on, 커서 off, 커서 깜빡임 off uint8_t command = 0x08 | (1 << COMMAND_DISPLAY_ON_OFF_BIT); LCD_write_command(command); LCD_clear(); // 화면 지움 // Entry Mode Set // 출력 후 커서를 오른쪽으로 옮김, 즉, DDRAM의 주소가 증가하며 화면 이동은 없음 LCD_write_command(0x06); }
int main(void) { LCD_init(); LCD_clear(); while(1) { uchar i; LCD_write_english_string(3,0,"WXJ_PCR"); LCD_write_english_string(0,2,"TIME="); LCD_write_num(5,2,31,2); LCD_write_english_string(7,2,":"); LCD_write_num(8,2,43,2); LCD_write_english_string(0,4,"NOW TEMP="); LCD_write_english_string(0,3,"AIM TEMP="); LCD_write_num(9,3,97,2); LCD_write_english_string(11,4,"."); LCD_write_english_string(0,5,"COUNT="); LCD_write_num(6,5,13,2); LCD_write_english_string(8,5,":"); LCD_write_num(9,5,35,2); temp = get_tmp(); sendchangecmd(); for(i=0;i<40;i++) { display(temp); } } }
/******************************************************************************* * Zobrazeni casu na displeji *******************************************************************************/ int display_idle() { long microseconds, milliseconds, seconds, minutes, hours; char buf[20]; if (isrunning) t = get_time(); microseconds = (long)(((float)(t - t0))*TIMER_TICK); milliseconds = (long)(microseconds / 1000) % 1000; seconds = (((long)(microseconds / 1000) - milliseconds) / 1000) % 60; minutes = (((((long)(microseconds / 1000) - milliseconds) / 1000) - seconds) / 60) % 60; hours = ((((((long)(microseconds / 1000) - milliseconds) / 1000) - seconds) / 60) - minutes) / 60; if (hours < 10) { buf[0] = '0'; long2str(hours, &buf[1], 10); } else { long2str(hours, &buf[0], 10); } buf[2] = ':'; if (minutes < 10) { buf[3] = '0'; long2str(minutes, &buf[4], 10); } else { long2str(minutes, &buf[3], 10); } buf[5] = ':'; if (seconds < 10) { buf[6] = '0'; long2str(seconds, &buf[7], 10); } else { long2str(seconds, &buf[6], 10); } buf[8] = '.'; if (milliseconds < 10) { buf[9] = '0'; buf[10] = '0'; long2str(milliseconds, &buf[11], 10); } else if (milliseconds < 100) { buf[9] = '0'; long2str(milliseconds, &buf[10], 10); } else { long2str(milliseconds, &buf[9], 10); } buf[12] = '\0'; LCD_clear(); LCD_append_string(buf); return 0; }
void LCD_init(void) { GPIO_WriteBit(GPIOC,GPIO_Pin_7,Bit_SET);//LCD_RST = 0; // 产生一个让LCD复位的低电平脉冲 GPIO_WriteBit(GPIO_LCD_RST_PORT,GPIO_LCD_RST,Bit_RESET);//LCD_RST = 0; delay_1us(); GPIO_WriteBit(GPIO_LCD_RST_PORT,GPIO_LCD_RST,Bit_SET);//LCD_RST = 1; // 关闭LCD GPIO_WriteBit(GPIO_LCD_CE_PORT,GPIO_LCD_CE,Bit_RESET);//LCD_CE = 0; delay_1us(); // 使能LCD GPIO_WriteBit(GPIO_LCD_CE_PORT,GPIO_LCD_CE,Bit_SET);//LCD_CE = 1; delay_1us(); LCD_write_byte(0x21, 0); // 使用扩展命令设置LCD模式 LCD_write_byte(0xc8, 0); // 设置偏置电压 LCD_write_byte(0x06, 0); // 温度校正 LCD_write_byte(0x13, 0); // 1:48 LCD_write_byte(0x20, 0); // 使用基本命令 LCD_clear(); // 清屏 LCD_write_byte(0x0c, 0); // 设定显示模式,正常显示 // 关闭LCD GPIO_WriteBit(GPIO_LCD_CE_PORT,GPIO_LCD_CE,Bit_RESET);//LCD_CE = 0; }
void initLCD(void) { //PORT configuration TRISB = 0x00; TRISD=0x00; ////////////////// LCD_Write(0x38,0); delay_ms(1); LCD_Write(0x0c,0); //dispaly on , cursor blinking delay_ms(1); LCD_Write(0x01,0); // clear dispaly screen delay_ms(1); LCD_Write(0x06,0); // LCD_Write(0x0F,0); //blinking cursor delay_ms(1); LCD_clear(); LCD_goto(1,0); LCD_Write('C',1);delay_ms(100);LCD_Write('l',1);delay_ms(100); LCD_Write('o',1);delay_ms(100);LCD_Write('c',1);delay_ms(100); LCD_Write('k',1);delay_ms(100); }
void mine_init(void){ unsigned char x, y; Func_id = MINE; mine_notdig_count = MINE_ROW * MINE_COL; mine_count = 0; mine_start_time = Timer_stamp_ms; mine_time = 0; mine_x = 0; mine_y = 0; mine_isover = 0; mine_success = 0; srand(Timer_stamp_ms); for(x = 0; x < MINE_COL; ++x){ for(y = 0; y < MINE_ROW; ++y){ if((rand() % 8 == 1)){ // 大于 100 表示是一个雷, 1 / 8 概率 mine_map[x][y] = 110; ++mine_count; }else{ mine_map[x][y] = 10; } } } LCD_clear(); mine_draw(); }
void LCD4884::LCD_init(void) { for(int i = 2; i < 8; i++) { pinMode(i,OUTPUT); digitalWrite(i,LOW); } digitalWrite(LCD_RST,LOW); delayMicroseconds(1); digitalWrite(LCD_RST,HIGH); digitalWrite(SPI_CS,LOW); delayMicroseconds(1); digitalWrite(SPI_CS,HIGH); delayMicroseconds(1); digitalWrite(LCD_BL,HIGH); LCD_write_byte(0x21, 0); LCD_write_byte(0xc0, 0); LCD_write_byte(0x06, 0); LCD_write_byte(0x13, 0); LCD_write_byte(0x20, 0); LCD_clear(); LCD_write_byte(0x0c, 0); digitalWrite(SPI_CS,LOW); }
// ============================ CBOT_main =================================== // void CBOT_main(void) { unsigned char sensors; // Initialize. init_bot(); // Clear the screen. LCD_clear(); printMainMenu(); while (1) { // Delay a little so that the 'Tiny is not overwhelmed with requests. TMRSRVC_delay( 100 ); // Wait 100ms. // Get state of all sensors. sensors = ATTINY_get_sensors(); if ( sensors & SNSR_SW3_EDGE ) { SPKR_play_tone( SPKR_FREQ( 293.7 ), 250, 80 ); all_pixel_test(); printMainMenu(); } else if ( sensors & SNSR_SW4_EDGE ) { SPKR_play_tone( SPKR_FREQ( 440 ), 250, 80 ); pixel_sensor_test(); printMainMenu(); } else if ( sensors & SNSR_SW5_EDGE ) { SPKR_play_tone( SPKR_FREQ( 659.3 ), 250, 80 ); draw_smiley(); printMainMenu(); } } }
// a function to draw a smiley face void draw_smiley (void){ int num = 0; while(checkNoBtns()) { TMRSRVC_delay(100); LCD_clear(); if (num % 2==0) { draw_face(); draw_smile(); TMRSRVC_delay(2000); } else { draw_face(); draw_frown(); TMRSRVC_delay(2000); } num++; for(unsigned char row = 0; row < LCD_PIX_HEIGHT; row++) { for( unsigned char col = 0; col < LCD_PIX_WIDTH; col++ ) { LCD_set_pixel(row, col, 0); } } } }
void DBG_testButtonState(S_robot* r, uint32_t repeats,uint32_t ms) { while(repeats>1) { repeats--; S_robot_buttons * b = &(r->btns); REFRESH_buttonState(b->bStart); REFRESH_buttonState(b->bLine); REFRESH_buttonState(b->bSumo); gpio_clear(PLED,LEDGREEN0|LEDORANGE1|LEDRED2|LEDBLUE3); LCD_clear(r->lcd); LCD_gotoxy(r->lcd,0,0); fprintf(R.flcd, "%x|%x|%x", b->bStart->state, b->bLine->state, b->bSumo->state ); if(b->bStart->state) gpio_set(PLED,LEDGREEN0); if(b->bLine->state) gpio_set(PLED,LEDBLUE3); if(b->bSumo->state) gpio_set(PLED,LEDRED2); mswait(ms); } gpio_clear(PLED,LEDGREEN0|LEDORANGE1|LEDRED2|LEDBLUE3);
int main(){ #ifndef TESTING #include "uart.h" #include "mmc.h" // Initializam modulele hardware uart_init(); SPI_init(); MMC_init(); BTN_init(); LCD_init(); #endif /* Gaseste prima partitie FAT32 de pe card*/ init_partition(buffer); /** * Gaseste datele despre sistemul de fisiere : * nr de tabele FAT, cluster-ul directorului Root, etc. */ initFAT32(buffer); print_volid(buffer); LCD_str( " ", 0); LCD_str( " ", 0); LCD_str( " Welcome to", 0); LCD_str( " MMC Explorer", 0); _delay_ms(2500); LCD_clear(); printdirs(openroot()); return EXIT_SUCCESS; }
void LCD_init(void) { // 产生一个让LCD复位的低电平脉冲 LCD_pin_config(); LCD_RST = 0; // delay_1us(); LCD_RST = 1; // 关闭LCD LCD_CE = 0; // delay_1us(); // 使能LCD LCD_CE = 1; delay_1us(); LCD_write_byte(0x21, 0); // 使用扩展命令设置LCD模式 LCD_write_byte(0xc0, 0); // 设置偏置电压 供电电压高时该值调小 LCD_write_byte(0x07, 0); // 温度校正 LCD_write_byte(0x13, 0); // 1:48 LCD_write_byte(0x20, 0); // 使用基本命令 LCD_clear(); // 清屏 LCD_write_byte(0x0c, 0); // 设定显示模式,正常显示 // 关闭LCD LCD_CE = 0; }
void LCD4884::LCD_init(void) { // LCD_RST = 0; DDRD |= (1 << SPI_CS) | (1 << LCD_DC) | (1 << LCD_RST) | (1 << SPI_MOSI) | (1 << SPI_SCK) | (1 << LCD_BL); PORTD &= ~(1 << LCD_RST); delayMicroseconds(1); PORTD |= (1 << LCD_RST); PORTD &= ~(1 << SPI_CS); delayMicroseconds(1); PORTD |= (1 << SPI_CS); delayMicroseconds(1); PORTD |= (1 << LCD_BL); // turn on backlight LCD_write_byte(0x21, 0); LCD_write_byte(0xc0, 0); LCD_write_byte(0x06, 0); LCD_write_byte(0x13, 0); LCD_write_byte(0x20, 0); LCD_clear(); LCD_write_byte(0x0c, 0); PORTD &= ~(1<<SPI_CS); }
void LCD_init(void) { SPI_DDR |= (1 << DC) | (1 << SCE) | (1 << RST) | (1 << SCK) | (1 << MOSI); SET_RST_PIN; SPCR = 0x50; //setup SPI TIMER_delay_ms(100); CLEAR_SCE_PIN; //Enable LCD CLEAR_RST_PIN; //reset LCD TIMER_delay_ms(100); SET_RST_PIN; SET_SCE_PIN; //disable LCD LCD_writeCommand(0x21); // LCD Extended Commands. LCD_writeCommand(0xE0); // Set LCD Vop (Contrast). LCD_writeCommand(0x04); // Set Temp coefficent. LCD_writeCommand(0x13); // LCD bias mode 1:48. LCD_writeCommand(0x20); // LCD Standard Commands, Horizontal addressing mode. LCD_writeCommand(0x0c); // LCD in normal mode. LCD_clear(); }
int main(void) { static volatile char count = 0; uint32_t temperature; Piezo_play(C5); Monitor_start(); LCD_clear(); LCD_setPos(16); LCD_printString("Temp:"); while (1) { // Get Monitor temperature temperature = Monitor_readTemp(1); LCD_setPos(22); LCD_printByteDec((uint8_t)temperature); LCD_printByte('/'); // Get CPU temperature temperature = Monitor_readTemp(0); LCD_printByteDec((uint8_t)temperature); LCD_printByte(0xdf); // degree symbol LCD_printByte('C'); LCD_printByte(' '); LCD_printByte(' '); // Display a rolling value so we know we're alive LCD_setPos(31); LCD_printByte(count); count++; } return 0; }
// Intialize display void LCD_initialize() { // ADC Select (Normal) LCD_writeControlReg( 0xA0 ); // LCD Off LCD_writeControlReg( 0xAE ); // COM Scan Output Direction LCD_writeControlReg( 0xC0 ); // LCD Bias (1/6 bias) LCD_writeControlReg( 0xA2 ); // Power Supply Operating Mode (Internal Only) LCD_writeControlReg( 0x2F ); // Internal Rb/Ra Ratio LCD_writeControlReg( 0x26 ); // Reset LCD_writeControlReg( 0xE2 ); // Electric volume mode set, and value LCD_writeControlReg( 0x81 ); LCD_writeControlReg( 0x00 ); // LCD On LCD_writeControlReg( 0xAF ); // Clear Display RAM LCD_clear(); }
void updateLCD() { // Prints the robot position variables to the LCD screen LCD_clear(); // Clears the LCD screen LCD_printf(" %3.2f\n%3.2f %3.2f\n %3.2f\nX:%2.2f Y:%2.2f",ft,lt,rt,bk,roboxpos,roboypos); }
int LCD_init(void) { uint8_t data[] = {0x00,0x35,0x00,0x9F,0x00,0x34,0x00,0x0C,0x00,0x02,0x00,0x01,0x00,0x80}; if (I2C_send(LCD,data,14) == 0) return 0; return (LCD_clear()); }
int main(void) { char str[32]; int temp_ms, temp_sec; RCONbits.SWDTEN = 0; //disable Watch dog timer initPLL(); while (OSCCONbits.CF == 1); //check clock failed while (OSCCONbits.COSC != 0b011); // Wait for Clock switch to occur while (OSCCONbits.LOCK == 0); //check PLL locked T1_Initial(); PORTS_Test_Initial(); keypad_init(); ADC1_Initial(); initPWM(); InitializeLCM(); LATDbits.LATD11 = 1; /* turn the LCM back light */ int a; LCD_clear(); LCD_start(); delay200usX(2*5000); LCD_clear(); while (1) { /* PWM */ infoPWM(); a = keypad_task(); /* LCD_Cursor_New(0, 12); sprintf(str, "%d",a); putsLCD((unsigned char*)str); *//* if(a==1){P1DC1 = 749; } if(a==2){P1DC1 = 3124; } if(a==3){P1DC1 = 4999; } if(a==4){P1DC1 = 6249; } */ if(a==1){P1DC1 = 1499; } if(a==2){P1DC1 = 6249; } if(a==3){P1DC1 = 9999; } if(a==4){P1DC1 = 12499; } } }