void lcd_clear_all( void ) { lcd_moveto_xy ( 0, 0 ); lcd_clear_area( 1, 132, NORMAL ); lcd_moveto_xy ( 1, 0 ); lcd_clear_area( 1, 132, NORMAL ); lcd_moveto_xy ( 2, 0 ); lcd_clear_area( 1, 132, NORMAL ); lcd_moveto_xy ( 3, 0 ); lcd_clear_area( 1, 132, NORMAL ); }
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; }
/****************************************************************************** * This function clears an area of the screen starting at the given coordinates * pages - height of area in pages * columns - width of area in pixels * style - style modifier * col - column of upper left corner * page - page of upper left corner * Cursor is moved to start of area after clear */ void lcd_clear_area_xy(uint8_t pages, uint8_t columns, uint8_t style, uint8_t page, uint8_t col) { lcd_moveto_xy(page,col); lcd_clear_area(pages,columns,style); }
/****************************************************************************** * Moves the cursor relative to the current position * pages - number of pages to move * columns - number of columns to move */ void lcd_move_xy(int8_t pages, int16_t columns) { lcd_moveto_xy(lcd_inc_page(pages),lcd_inc_column(columns)); }
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); } }
/****************************************************************************** * Initializes the display in 6 o'clock mode, 4x booster for 2.4-3.3V supply voltage * scheme according to datasheet * Suitable for all DOGS, DOGM and DOGL displays. */ void lcd_init() { //for better understanding -> write macros in clear text //set outputs //LCD_SET_PIN_DIRECTIONS(); DDR_A0 |= (1<<PIN_A0); DDR_RST |= (1<<PIN_RST); DDR_CS |= (1<<PIN_CS); //Initialize SPI Interface //LCD_INIT_SPI(); init_spi_lcd(); //Apply Reset to the Display Controller //LCD_RESET(); PORT_RST &= ~(1<<PIN_RST); _delay_ms(1); PORT_RST |= (1<<PIN_RST); //Load settings //(2) LCD_SET_FIRST_LINE(0); //first bit in RAM is on the first line of the LCD // | // --> lcd_command(LCD_START_LINE | ((i) & 0x3F)) // -> LCD_START_LINE = display start line 0 //without this delay the content is displayed mirror inverted _delay_ms(1); //(8) LCD_SET_BOTTOM_VIEW(); //6 o'clock mode, normal orientation // | // --> lcd_command(LCD_BOTTOMVIEW) // -> LCD_BOTTOMVIEW = ADC reverse //_delay_ms(1); //(15) LCD_ORIENTATION_NORMAL(); // | // --> lcd_command(LCD_SCAN_DIR_NORMAL) // -> LCD_SCAN_DIR_NORMAL = Normal COM0 - COM31 //without this delay the content is displayed mirror inverted _delay_ms(1); //(10) //LCD_SHOW_ALL_PIXELS_OFF(); //Normal Pixel mode // | // --> lcd_command(LCD_SHOW_NORMAL) // -> LCD_SHOW_NORMAL = display all points, normal display (10) //(9) LCD_SET_MODE_POSITIVE(); //positive display // | // --> lcd_command(LCD_DISPLAY_POSITIVE) // -> LCD_DISPLAY_POSITIVE = sets display normal (9) #if DISPLAY_TYPE == 132 //(11) LCD_SET_BIAS_RATIO_1_9(); //bias 1/9 // | // --> lcd_command(LCD_BIAS_1_9) //(16) LCD_SET_POWER_CONTROL(7); //power control mode: all features on // | // --> lcd_command(LCD_POWER_CONTROL | ((i) & 0x07)) // -> command 16 with operating mode = 0b111 //(20) -> selbst eingefügtes macro LCD_SET_BOOSTER_RATIO(); //(17) LCD_SET_BIAS_VOLTAGE(3); //set voltage regulator R/R // | // --> lcd_command(LCD_VOLTAGE | ((i) & 0x07)) // -> command 17 with resistor ration 0b011 //(18) LCD_SET_VOLUME_MODE(0x1F); //volume mode set // | // --> lcd_command(LCD_VOLUME_MODE_1) // -> standard command 18 // --> lcd_command(LCD_VOLUME_MODE_2 | ((i) & 0x3F)) // -> command 18 with electronic volume value 0b011111 //(19) LCD_SET_INDICATOR_OFF(); //switch indicator off, no blinking // | // --> passt scho #endif #if DISPLAY_TYPE == 128 LCD_SET_BIAS_RATIO_1_7(); //bias 1/7 LCD_SET_POWER_CONTROL(7); //power control mode: all features on LCD_SET_BIAS_VOLTAGE(7); //set voltage regulator R/R LCD_SET_VOLUME_MODE(0x06); //volume mode set LCD_SET_INDICATOR_OFF(); //switch indicator off, no blinking #endif #if DISPLAY_TYPE == 102 LCD_SET_BIAS_RATIO_1_9(); //bias 1/9 LCD_SET_POWER_CONTROL(7); //power control mode: all features on LCD_SET_BIAS_VOLTAGE(3); //set voltage regulator R/R LCD_SET_VOLUME_MODE(0x1F); //volume mode set LCD_SET_ADV_PROG_CTRL(LCD_TEMPCOMP_HIGH); #endif uint8_t i,j; //clear display content for(j=0;j<LCD_RAM_PAGES;j++) { lcd_moveto_xy(j,0); // array (uint8_t page, uint8_t column) for (i=0;i<LCD_WIDTH;i++) lcd_data(0); } lcd_moveto_xy(0,0); //Set write pointer LCD_SWITCH_ON(); //Switch display on (1) return; }
//######################################### //######################################### //######################################### // 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; }