void DISPLAY_Init() { HD44780_Init(); display_busy = 0; /* HD44780_LocationSet(DISPLAY_POS_RPM_X + 6, DISPLAY_POS_RPM_Y); HD44780_DisplayString("rpm"); HD44780_LocationSet(DISPLAY_POS_DUTY_X, DISPLAY_POS_DUTY_Y); HD44780_DisplayString("duty:"); HD44780_LocationSet(DISPLAY_POS_DUTY_X+ 10, DISPLAY_POS_DUTY_Y); HD44780_DisplayString("%"); */ // HD44780CursorOn(xfalse); // HD44780CursorOff(); }
int main(void) { HD44780_Init(); SYS_SysTickDelay(2000000); HD44780_DisplayString("Hello World!"); while(1) { /* P04 = 0; SYS_SysTickDelay(500); P04 = 1; SYS_SysTickDelay(500); */ } }
int main(void) { ANCON0 = 0XFF; /*Desactivamos las entradas analogicas*/ ANCON1 = 0XFF; /*Desactivamos las entradas analogicas*/ System_EnablePLL(); /*uC a 48MHz*/ HD44780_Init(); /*inicliza el LCD*/ xdev_out(HD44780_WriteData); /*establece elcd como salida*/ xprintf("Tengo %d edad", (_U16)29); /*imprime una cadena de caracteres*/ HD44780_SetCursor(2, 0); /*se cambia el cursor a la linea 2 columna 5*/ xprintf("Hoy es %d de %d", (_U16)30, (_U16)1984); /*se imprime otra linea de caracteres*/ while (1) { } }
int main(int argc, char **argv) { uint32_t i; uint8_t accelRc, gyroRc; /* Configure the system clock */ SystemClock_Config(); HAL_Init(); TerminalInit(); /* Initialize UART and USB */ /* Configure the LEDs... */ for(i=0; i<numLEDs; i++) { BSP_LED_Init(LEDs[i]); } /* Initialize the pushbutton */ BSP_PB_Init(BUTTON_USER, BUTTON_MODE_GPIO); /* Initialize the Accelerometer */ accelRc = BSP_ACCELERO_Init(); if(accelRc != ACCELERO_OK) { printf("Failed to initialize acceleromter\n"); Error_Handler(); } /* Initialize the Gyroscope */ gyroRc = BSP_GYRO_Init(); if(gyroRc != GYRO_OK) { printf("Failed to initialize Gyroscope\n"); Error_Handler(); } HD44780_Init(); // lcd init HD44780_PutStr("Hello World!"); hd44780_wr_cmd(0xC0); // to change curser to next line HD44780_PutStr("Hello Test !"); //print text while(1) { TaskInput(); } return 0; }
HD44780_RESULT confHD44780(void) { hd44780.i2c = &i2c_handle; hd44780.pcf8574_handle = &pcf_handle; hd44780.HD44780_GPIOx = GPIOB; hd44780.HD44780_I2C_SPEED = 100000; hd44780.HD44780_I2Cx = I2C1; hd44780.HD44780_INTERFACE = HD44780_INTERFACE_PCF8574; hd44780.HD44780_NUMBER_OF_LINES = NUMBER_OF_LINES_2; hd44780.HD44780_PIN_D4 = 4; hd44780.HD44780_PIN_D5 = 5; hd44780.HD44780_PIN_D6 = 6; hd44780.HD44780_PIN_D7 = 7; hd44780.HD44780_PIN_E = 2; hd44780.HD44780_PIN_LED = 3; hd44780.HD44780_PIN_RS = 0; hd44780.HD44780_PIN_RW = 1; hd44780.HD44780_SLAVE_ADDRESS = 0x4E; hd44780.HD44780_TIMEOUT = 1000; hd44780.HD44780_USE_BUFFER = 0; return HD44780_Init(&hd44780); }
/* StartDefaultTask function */ void StartDefaultTask(void const * argument) { /* USER CODE BEGIN StartDefaultTask */ uint32_t i=0; char dispbuf[33]; HD44780_Init(); osDelay(500); HD44780_print("RTOS started...", 16); osDelay(500); osDelay(500); /* Infinite loop */ for(;;) { sprintf(dispbuf, "Heepy %lu.", i++); HD44780_print(dispbuf, 16); HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12, GPIO_PIN_SET); osDelay(100); HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12, GPIO_PIN_RESET); osDelay(400); } /* USER CODE END StartDefaultTask */ }
void main(void){ unsigned char i,cmd, param[9], tmp; unsigned long lhfe; //unsigned char t[]={"Hello World"}; init(); //setup the crystal, pins Delay_MS(10); HD44780_Reset();//setup the LCD HD44780_Init(); //LCD_Backlight(1);//turn it on, we ignore the parameter LCD_CursorPosition(0); LCD_WriteString("Part Ninja v0.0a"); LCD_CursorPosition(21); LCD_WriteString(" testing..."); while(1){ PartType=0; PartMode=0; RepeatDetect=0; checkpins(0, 1, 2); //CBE npn -- checkpins(0, 2, 1); //CBE npn checkpins(1, 0, 2); //CBE npn -- checkpins(1, 2, 0); //CBE npn checkpins(2, 0, 1); //CBE npn checkpins(2, 1, 0); //CBE npn if(PartType==PART_TRANSISTOR){ if(RepeatDetect==0){ hfe[1] = hfe[0]; vBE[1] = vBE[0]; } if(hfe[0]>hfe[1]){ hfe[1] = hfe[0]; vBE[1] = vBE[0]; tmp = c; c = e; e = tmp; } lhfe = hfe[1]; lhfe *= (((unsigned long)4700 * 100) / (unsigned long)680); //Verhältnis von High- zu Low-Widerstand if(vBE[1]<11) vBE[1] = 11; lhfe /= vBE[1]; hfe[1] = (unsigned int) lhfe; LCD_Clear(); LCD_CursorPosition(0); if(PartMode == PART_MODE_NPN) { LCD_WriteString("NPN "); } else if (PartMode==PART_MODE_PNP) { LCD_WriteString("PNP "); } LCD_WriteString(" hFE:"); LCD_WriteByteVal(hfe[1]); LCD_CursorPosition(21); LCD_WriteString("C="); LCD_WriteChar(c+0x31); LCD_WriteString(" B="); LCD_WriteChar(b+0x31); LCD_WriteString(" E="); LCD_WriteChar(e+0x31); }else if(PartType==PART_FET){ LCD_Clear(); LCD_CursorPosition(0); if(PartMode == PART_MODE_NPN) { LCD_WriteString("N-"); } else if (PartMode==PART_MODE_PNP) { LCD_WriteString("P-"); } LCD_WriteString("FET "); f=gthvoltage; f=((f)/1024)*5; gthvoltage=f; LCD_WriteString(" Vth:"); LCD_WriteByteVal(gthvoltage); //lcd_data('m'); LCD_WriteString("v"); LCD_CursorPosition(21); LCD_WriteString("G="); LCD_WriteChar(b+0x31); LCD_WriteString(" D="); LCD_WriteChar(c+0x31); LCD_WriteString(" S="); LCD_WriteChar(e+0x31); } } }//end main
void Display_Init(void) { HD44780_Init(HD44780_WIDTH,HD44780_HEIGHT); xTaskCreate(Display_Task,(signed char*)"DISPLAY_TASK",128,NULL, tskIDLE_PRIORITY + 1, NULL); // task_watches[DISPLAY_TASK].task_status=TASK_IDLE; }
int main(void) { TRIS_KEY1 = 1; TRIS_KEY2 = 1; TRIS_LED1 = 0; TRIS_LED2 = 0; LAT_LED1 = 0; LAT_LED2 = 0; /* External Interrupts Configuration */ INTCONbits.INT0E = 1; /* Enable Interrupt 0 (RB0 as interrupt) */ INTCON2bits.INTEDG0 = 1; /* Cause Interrupt 0 at rising edge */ INTCONbits.INT0F = 0; /* Clear Interrupt 0 flag */ INTCON3bits.INT1E = 1; /* Enable Interrupt 1 (RB1 as interrupt) */ INTCON2bits.INTEDG1 = 1; /* Cause Interrupt 1 at rising edge */ INTCON3bits.INT1F = 0; /* Clear Interrupt 0 flag */ ei(); /* Global Interrupt Enable */ /* Initialize LCD 16 cols x 2 rows */ HD44780_Init(16, 2); HD44780_Puts(3, 0, "PIC18F4520"); HD44780_Puts(0, 1, "16x2 HD44780 LCD"); Delayms(2000); SSEG_Init(); KEYPAD_Init(); OpenADC(ADC_FOSC_4 & ADC_RIGHT_JUST & ADC_0_TAD, ADC_CH0 & ADC_REF_VDD_VSS & ADC_INT_OFF, ADC_1ANA); Delay(50); /* Loop forever */ while(1) { if (state == STATE_LCD) { counter = 0; lcd_flag = 0; while(lcd_flag == 0) { HD44780_Clear(); Delayms(250); HD44780_Clear(); HD44780_Puts(0, 0, "1.LCD TEST"); HD44780_Puts(0, 1, "<<ADC LED>>"); Delayms(250); counter++; if(counter > 3) {counter = 0; break;} } HD44780_Clear(); HD44780_Puts(0, 0, "1.LCD TEST"); HD44780_Puts(0, 1, "<<ADC LED>>"); while(lcd_flag == 0){ HD44780_Clear(); HD44780_Puts(0, 0, "PRESS KEY1 FOR"); HD44780_Puts(0, 1, "LEFT"); Delayms(500); HD44780_Clear(); HD44780_Puts(0, 0, "PRESS KEY2 FOR"); HD44780_Puts(0, 1, "RIGHT"); Delayms(500); counter++; if(counter > 3) {counter = 0; break;} } } else if (state == STATE_LED) { counter = 0; led_flag = 0; while(led_flag == 0) { HD44780_Clear(); Delayms(250); HD44780_Clear(); HD44780_Puts(0, 0, "2.LED TEST"); HD44780_Puts(0, 1, "<<LCD SSEG>>"); Delayms(250); counter++; if(counter > 3) {counter = 0; break;} } HD44780_Clear(); HD44780_Puts(0, 0, "2.LED TEST"); HD44780_Puts(0, 1, "<<LCD SSEG>>"); while(led_flag == 0) { LAT_LED1 = 1; LAT_LED2 = 0; Delayms(50); LAT_LED1 = 0; LAT_LED2 = 1; Delayms(50); } LAT_LED2 = 0; } else if (state == STATE_SSEG) { counter = 0; sseg_flag = 0; while(sseg_flag == 0) { HD44780_Clear(); Delayms(250); HD44780_Clear(); HD44780_Puts(0, 0, "3.SSEG TEST"); HD44780_Puts(0, 1, "<<LED KEYPAD>>"); Delayms(250); counter++; if(counter > 3) {counter = 0; break;} } HD44780_Clear(); HD44780_Puts(0, 0, "3.SSEG TEST"); HD44780_Puts(0, 1, "<<LED KEYPAD>>"); while(sseg_flag == 0) { SSEG_Print(1,sseg_counter%10); Delayms(10); SSEG_Print(2,sseg_counter/10); Delayms(10); sseg_counter++; if(sseg_counter > 99) sseg_counter = 0; } LATCbits.LATC0 = 0; LATCbits.LATC5 = 0; } else if (state == STATE_KEYPAD) { counter = 0; keypad_flag = 0; while(keypad_flag == 0) { HD44780_Clear(); Delayms(250); HD44780_Clear(); HD44780_Puts(0, 0, "4.KEYPAD TEST"); HD44780_Puts(0, 1, "<<SSEG ADC>>"); Delayms(250); counter++; if(counter > 3) {counter = 0; break;} } HD44780_Clear(); HD44780_Puts(0, 0, "4.KEYPAD TEST"); HD44780_Puts(0, 1, "<<SSEG ADC>>"); while(keypad_flag == 0) { int_key = KEYPAD_Read(); char_key = (char)KEYPAD_KeytoASCII(int_key); HD44780_CursorSet(0,0); if(int_key != 0xFF) printf("4.KEYPAD TEST: %c", char_key); Delayms(50); } } else if (state == STATE_ADC) { counter = 0; adc_flag = 0; while(adc_flag == 0) { HD44780_Clear(); Delayms(250); HD44780_Clear(); HD44780_Puts(0, 0, "5.ADC TEST"); HD44780_Puts(0, 1, "<<KEYPAD LCD>>"); Delayms(250); counter++; if(counter > 3) {counter = 0; break;} } HD44780_Clear(); HD44780_Puts(0, 0, "5.ADC TEST"); HD44780_Puts(0, 1, "<<KEYPAD LCD>>"); while(adc_flag == 0){ ConvertADC(); while( BusyADC() ); adcin = 1023 - ReadADC(); dcf_old = dcf; dcf = (1-lamda)*dcf + lamda*adcin; if(dcf != dcf_old) { HD44780_CursorSet(0,0); printf("5.ADC TEST: %4d", (int)dcf); } } } else state = STATE_LCD; } }
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
/** * @brief Initializes the LCD * @details Initializes necessary IO and sets up the display */ void lcd_init(void) { HD44780_Init(); }