int main (void) { board_init(); // Insert application code here, after the board has been initialized. lcd_init(); lcd_cls(); lcd_locate(0,0); lcd_set_font(Lcd_Font_5x7); lcd_write_s(c_GreetingMsg); /* Initialize the PWM driver and set proper frequency */ pwm_init(); pwm_set_duty(0); pwm_set_frequency(Pwm_31250Hz); /* Initialize the encoder and register a callback function */ encoder_init(); encoder_register_event(OnEncoderEvent); while(1) { encoder_cyclic(); switch(CurrentState) { case State_Info: // info_cyclic(&CurrentEventMask); CurrentState = State_MainMenu; break; case State_MainMenu: CurrentState = main_menu_cyclic(MainMessagePump); break; case State_Reflow: // refow_cyclic(); CurrentState = State_MainMenu; break; case State_Learn: // learn_cyclic(); CurrentState = State_MainMenu; break; case State_Parameterize: // parameterize_cyclic(); CurrentState = State_MainMenu; break; default: CurrentState = State_MainMenu; break; } } }
int main(void) { //variables int8_t compareValue = 31; cli(); //Variablen myInit(); pwm_init(); pwm_update(compareValue); //lcd ouput: lcd_put_string_P(FONT_FIXED_8, NORMAL, PSTR("pos(page/column): ")); //currentPage = lcd_get_position_page(); //currentColumn = lcd_get_position_column(); //lcd_put_short(currentPage); //lcd_put_string_P(FONT_FIXED_8, NORMAL, PSTR("/")); //lcd_put_short(currentColumn); lcd_moveto_xy (1, 0); lcd_set_font(FONT_FIXED_8,NORMAL); lcd_put_string_P(FONT_FIXED_8, NORMAL, PSTR("PWM Wert: ")); lcd_put_short(compareValue); while(1) { } return 0; }
void main (void) { uint16_t sensorRead; unsigned char msgBuf[2]; uint16_t statusCode; sei(); myInit(); TWI_Master_Initialise(); //pwmInit(100); lcd_set_font(FONT_FIXED_8,NORMAL); lcd_put_string_P(FONT_FIXED_8, NORMAL, PSTR("Init ... done!")); while(1) { sensorRead+=1; //_delay_ms(200); //TWEN: twi module enable //TWSTA: twi start condition -> generates a start contition on the bus (it it is free) // if it is not free, it waits until a stop condition is // detected //TWIE: the interrupt request for twi will be activated as long as the twint flag is high //TWINT: reset twint flag (by writing a one) -> starts the operation of the twi module TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN);// | (1<<TWIE); //TWSR should now have the status code, that the START has been send successfully statusCode = TWSR; lcd_moveto_xy (1, 0); lcd_put_uint(statusCode); //after the START has been send, the TWINT flag is set 0 (wait until it is 0) //while (!(TWCR & (1<<TWINT))); //write the bmp addressWrite into the TWI data register TWDR = 0xEE; //start transmission by reseting the TWINT (by writing a one) TWCR = (1<<TWINT) | (1<<TWEN); //while (!(TWCR & (1<<TWINT))); TWDR = 0xF4; TWCR = (1<<TWINT) | (1<<TWEN); //while (!(TWCR & (1<<TWINT))); TWDR = 0xF4; TWCR = (1<<TWINT) | (1<<TWEN); //send STOP condition TWCR = (1<<TWINT) | (1<<TWEN)| (1<<TWSTO); //TWSR should now have the status code, that the slave has accepted the data package statusCode = TWSR; lcd_moveto_xy (2, 0); lcd_put_uint(statusCode); //readInternalRegister(0xAA); //sensorRead = readInternalRegister(0xAA); //lcd_moveto_xy (2, 0); //lcd_put_string_P(FONT_FIXED_8, NORMAL, PSTR("Task1")); //lcd_put_uint(sensorRead); _delay_ms(100); } }
int main(void) { uint16 i =0; // char ch = 0x01; gpio_init(); //Init GPIO's //spi_init(); //Init SPI0 lcd_init(); lcd_clear(ILI9341_White); //lcd_set_Orientation(rot270); lcd_set_font(&Font13x16, true); //lcd_write_center_string(10,"Test"); lcd_draw_rect(0,240,120,160,ILI9341_Navy,true); lcd_set_font_color(ILI9341_White); lcd_set_background_color(ILI9341_Navy); lcd_set_font(&Font8x11, true); lcd_write_center_string(145,"G A S S M A N N"); lcd_set_font(&Font13x16, true); lcd_write_center_string(125,"PCS - 2020"); lcd_draw_rect(0,240,0,20,ILI9341_GRAY1,true); lcd_draw_line(0,240,20,20,ILI9341_Black); lcd_draw_circle(120, 60,20,ILI9341_Red); lcd_set_font_color(ILI9341_Black); //lcd_set_background_color(ILI9341_White); lcd_set_background_color(ILI9341_GRAY1); lcd_draw_bitmap(60,5,&IPOD_SYMBOL); lcd_draw_bitmap(70,5,&FM_SYMBOL); lcd_draw_bitmap(80,5,&IR_SYMBOL); lcd_set_background_color(ILI9341_GRAY1); lcd_draw_battery(200, 5, 50); lcd_write_digit(5,200, 3, 9); lcd_send_cmd(ILI9341_DISPON); //Display on while (1) { OUTPUT_TOGGLE(GREEN_LED); delay(); lcd_set_background_color(ILI9341_GRAY1); lcd_draw_battery(200, 5, i%100); //lcd_set_background_color(i); lcd_set_background_color(ILI9341_White); //lcd_set_font_color(i); lcd_write_digit(5,200, i++%10, 9); //OUTPUT_TOGGLE(RED_LED); //delay(); //OUTPUT_TOGGLE(BLUE_LED); //delay(); //delay(); //spi_send(ch); //Send char over SPI } }
//######################################### //######################################### //######################################### // S T A R T M A I N P R O G R A M int main(void) { //----------------------------------------- // Allocate memory //----------------------------------------- int32_t temperature = 0; int32_t pressure = 0; int16_t BMP085_calibration_int16_t[8]; int16_t BMP085_calibration_uint16_t[3]; uint8_t error_code=0; int32_t altitude=0; //----------------------------------------- // Initialize Stuff //----------------------------------------- //uart_init(); //Initialize UART0 volatile int16_t testVar; _delay_ms(11); i2cSetBitrate(1000); //Initialize TWI 1000kHz BMP085_Calibration(BMP085_calibration_int16_t, BMP085_calibration_uint16_t,&error_code);////Initialize BMP085 lcd_init(); lcd_set_font(FONT_FIXED_8,NORMAL); //----------------------------------------- // Do forever //----------------------------------------- //printf("error code global init: %d \n",error_code); while(1) { /* printf("------------------------\n"); printf("------------------------\n"); printf("Pressure raw %ld \n",bmp085ReadPressure(&error_code)); printf("error code global: %d \n",error_code); printf("------------------------\n"); printf("------------------------\n"); printf("Temperature raw %ld \n",bmp085ReadTemp(&error_code)); printf("error code global: %d \n",error_code); printf("------------------------\n"); printf("------------------------\n"); */ bmp085Convert(BMP085_calibration_int16_t, BMP085_calibration_uint16_t,&temperature, &pressure,&error_code); lcd_moveto_xy (1, 0); lcd_put_string_P(FONT_FIXED_8, NORMAL, PSTR("Temp: ")); lcd_put_int((int16_t)temperature); lcd_moveto_xy (2, 0); lcd_put_string_P(FONT_FIXED_8, NORMAL, PSTR("Pressure: ")); lcd_put_int((int16_t)pressure); altitude = bmp085CalcAltitude (pressure); lcd_moveto_xy (3, 0); lcd_put_string_P(FONT_FIXED_8, NORMAL, PSTR("Altitude: ")); lcd_put_int((int16_t)altitude); /* printf("Temperature: %ld (in 0.1 deg C)\n", temperature); printf("Pressure: %ld Pa\n\n", pressure); printf("Altitude: %ld dm\n", bmp085CalcAltitude(pressure)); printf("error code global: %d \n",error_code); printf("------------------------\n"); printf("------------------------\n"); */ _delay_ms(200); } return 0; }