int output_time_setting(void){
	// Get binary values + convert to ascii string
	bin_to_ascii(get_seconds_setting(), secondSettingASCII);
	bin_to_ascii(get_minutes_setting(), minuteSettingASCII);
	bin_to_ascii(get_hours_setting(), hourSettingASCII);
	// Send to LCD
	lcd_send_cmd(LINE2);
	lcd_printf(hourSettingASCII); lcd_printf(":");
	lcd_printf(minuteSettingASCII); lcd_printf(":");
	lcd_printf(secondSettingASCII);
	return 0;
}
int output_date_setting(void){
	// Get binary values + convert to ascii string
	bin_to_ascii(get_day_setting(), daySettingASCII);
	bin_to_ascii(get_month_setting(), monthSettingASCII);
	bin_to_ascii(get_year_setting(), yearSettingASCII);
	// Send to LCD
	lcd_send_cmd(LINE2);
	lcd_printf(daySettingASCII); lcd_printf("-");
	lcd_printf(monthSettingASCII); lcd_printf("-");
	lcd_printf(yearSettingASCII);
	return 0;
}
Example #3
0
void lcd_set_pos(uint8_t verse, uint8_t column)
{
	uint8_t position = 0x00;

	if(verse == 1)
		position = DDRAM_LINE1;
	else if(verse == 2)
		position = DDRAM_LINE2;

	position += column;

	lcd_send_cmd(DDRAM + position);
}
Example #4
0
void lcd_set_pos2(position const *pos)
{
	uint8_t tmp = 0x00;

		if(pos->verse == 1)
			tmp = DDRAM_LINE1;
		else if(pos->verse == 2)
			tmp = DDRAM_LINE2;

		tmp += pos->column;

		lcd_send_cmd(DDRAM + tmp);
}
Example #5
0
/* Performance function that works with an external buffer
   note that by and bheight are in 8-pixel units! */
void lcd_blit_mono(const unsigned char *data, int x, int by, int width,
                   int bheight, int stride)
{
    const unsigned char *src, *src_end;
    unsigned char *dst_u, *dst_l;
    static unsigned char upper[LCD_WIDTH] IBSS_ATTR;
    static unsigned char lower[LCD_WIDTH] IBSS_ATTR;
    unsigned int byte;

    by *= 2;

    while (bheight--)
    {
        src = data;
        src_end = data + width;
        dst_u = upper;
        dst_l = lower;
        do
        {
            byte = *src++;
            *dst_u++ = lcd_dibits[byte & 0x0F];
            byte >>= 4;
            *dst_l++ = lcd_dibits[byte & 0x0F];
        }
        while (src < src_end);

        lcd_write_reg_ex(LCD_CNTL_PAGE, by++, -1);
        lcd_write_reg_ex(LCD_CNTL_COLUMN, x, -1);
        lcd_send_cmd(LCD_CNTL_DATA_WRITE);
        lcd_write_data(upper, width);

        lcd_write_reg_ex(LCD_CNTL_PAGE, by++, -1);
        lcd_write_reg_ex(LCD_CNTL_COLUMN, x, -1);
        lcd_send_cmd(LCD_CNTL_DATA_WRITE);
        lcd_write_data(lower, width);

        data += stride;
    }
}
//---------------------------------------------------------------------------------------
//Output Date (dd-mm-yy) & Time (hh:mm:ss)
int output_date_time(void){
	// Get the current date and time
	ds1307_read_date_time();
	// Get binary values + convert to ascii string
	bin_to_ascii(get_seconds(), secondASCII);
	bin_to_ascii(get_minutes(), minuteASCII);
	bin_to_ascii(get_hours(), hourASCII);
	bin_to_ascii(get_day(), dayASCII);
	bin_to_ascii(get_month(), monthASCII);
	bin_to_ascii(get_year(), yearASCII);
	// Send to LCD
	lcd_send_cmd(LINE1);
	lcd_printf(hourASCII); lcd_printf(":");
	lcd_printf(minuteASCII); lcd_printf(":");
	lcd_printf(secondASCII);
	lcd_send_cmd(LINE2);
	lcd_printf(dayASCII); lcd_printf("-");
	lcd_printf(monthASCII); lcd_printf("-");
	lcd_printf(yearASCII);
		
	return 0;
}
Example #7
0
/* Performance function that works with an external buffer
   note that by and bheight are in 4-pixel units! */
void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
                         int x, int by, int width, int bheight, int stride)
{
    stride <<= 2; /* 4 pixels per block */
    while (bheight--)
    {
        lcd_write_reg_ex(LCD_CNTL_PAGE, by++, -1);
        lcd_write_reg_ex(LCD_CNTL_COLUMN, x, -1);
        lcd_send_cmd(LCD_CNTL_DATA_WRITE);
        lcd_grey_data(values, phases, width);
        values += stride;
        phases += stride;
    }
}
//---------------------------------------------------------------------------------------
//Output Stopwatch (hh:mm:ss:msms)
int output_stopwatch(void){
	// Convert to ASCII
	bin_to_ascii(get_stopwatch_hour(), stopwatchHourASCII);
	bin_to_ascii(get_stopwatch_min(), stopwatchMinuteASCII);
	bin_to_ascii(get_stopwatch_sec(), stopwatchSecondASCII);
	bin_to_ascii(get_stopwatch_msec(), stopwatchMSecondASCII);
	// Send to LCD
	lcd_send_cmd(LINE2);
	lcd_printf(stopwatchHourASCII); lcd_printf(":");
	lcd_printf(stopwatchMinuteASCII); lcd_printf(":");
	lcd_printf(stopwatchSecondASCII); lcd_printf(":");
	lcd_printf(stopwatchMSecondASCII);
	
	return 0;
}
//---------------------------------------------------------------------------------------
//Output Heartrate (xxx BPM)
int output_heartrate(void){
	// Get heartrate
	unsigned char heartrate = get_heartrate();
	// Send to LCD
	lcd_send_cmd(LINE1);
	if(heartrate == 0){
		lcd_printf("---");
	}
	else{
		lcd_printf(three_digit_bin_to_ascii(heartrate));
	}
	lcd_printf(" BPM");
	
	return 0;
}
Example #10
0
/*
 * Initializes the LCD.  Should be called during the initialization of the 
 * program.
 *
 * Parameters:
 *      set_function    See LCD_FUNCTION_* definitions in lcd.h
 *      set_entry_mode  See LCD_CMD_ENTRY_* definitions in lcd.h
 *      on              See LCD_CMD_ON_* definitions in lcd.h
 
 
*/
void
lcd_initialize(uint8_t set_function, uint8_t set_entry_mode, uint8_t on)
{
        /* 20ms delay while LCD powers on */
        _delay_ms(30);	   
        
        /* Write 0x30 to LCD and wait 5 mS for the instruction to complete */
        lcd_load_byte(0x30);
        lcd_send_cmd();
        _delay_ms(10);
        
        /* Write 0x30 to LCD and wait 160 uS for instruction to complete */
        lcd_load_byte(0x30);
        lcd_send_cmd();
        _delay_us(20);
        
        /* Write 0x30 AGAIN to LCD and wait 160 uS */
        lcd_load_byte(0x30);
        lcd_send_cmd();
        _delay_us(160);
        
        /* Set function and wait 40uS */
        lcd_load_byte(set_function);
        lcd_send_cmd();
        
        /* Turn off the display and wait 40uS */
        lcd_load_byte(LCD_CMD_OFF);    
        lcd_send_cmd();
        
        /* Clear display and wait 1.64mS */
        lcd_load_byte(LCD_CMD_CLEAR);    
        lcd_send_cmd();
        _delay_ms(4);
        
        /* Set entry mode and wait 40uS */
        lcd_load_byte(set_entry_mode);    
        lcd_send_cmd();
        _delay_ms(4);
        /* Turn display back on and wait 40uS */
        lcd_load_byte(on);    
        lcd_send_cmd();
		_delay_ms(40);
};
Example #11
0
static void lcd_write_reg_ex(unsigned cmd, unsigned data0, unsigned data1)
{
    lcd_send_cmd(cmd);
    lcd_send_data(data0);
    lcd_send_data(data1);
}
Example #12
0
void lcd_clr()
{
	lcd_send_cmd(CLR_DISP);
}
Example #13
0
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
    }
}
int output_change_year(void){
	lcd_send_cmd(LINE1);
	lcd_printf("Set year");
	output_date_setting();
	return 0;
}
Example #15
0
static void lcd_write_reg(unsigned cmd, unsigned data)
{
    lcd_send_cmd(cmd);
    lcd_send_data(data);
}
int clear_output(void){
	lcd_send_cmd(DISP_CLR);
	return 0;
}
int output_change_month(void){
	lcd_send_cmd(LINE1);
	lcd_printf("Set month");
	output_date_setting();
	return 0;
}
Example #18
0
void lcd_cursor_home()
{
	lcd_send_cmd(CURSOR_HOME);
}
int output_change_sec(void){
	lcd_send_cmd(LINE1);
	lcd_printf("Set seconds");
	output_time_setting();
	return 0;
}
Example #20
0
void lcd_clear()
{
	lcd_send_cmd(1, true);
	lcd_x = 0;
	lcd_y = 0;
}
int output_avg_heartrate(void){
	lcd_send_cmd(LINE1);
	lcd_printf("AVG HR: "); lcd_printf(three_digit_bin_to_ascii(get_avg_heartrate())); lcd_printf(" BPM");
	return 0;
}
Example #22
0
void lcd_cursor_on()
{
	lcd_send_cmd(DISP_ON| TURN_ON | CURSOR_ON);
}
Example #23
0
void lcd_cursor_off()
{
	lcd_send_cmd(DISP_ON|TURN_ON);
}
Example #24
0
void lcd_cursor_and_blink_on()
{
	lcd_send_cmd(DISP_ON| TURN_ON | CURSOR_ON | CURSOR_BLINK);
}
//---------------------------------------------------------------------------------------
//Output Data
int output_no_data(void){
	lcd_send_cmd(LINE1);
	lcd_printf("No data");
	return 0;
}
//---------------------------------------------------------------------------------------
//Output Settings (Set hour/minutes/seconds/day/month/year)
//				  (hh:mm:ss/dd-mm-yy)
int output_change_hour(void){
	lcd_send_cmd(LINE1);
	lcd_printf("Set hour");
	output_time_setting();
	return 0;
}
Example #27
0
// Set cursor position
void lcd_cursorpos(int row, int col) {
  lcd_send_cmd(0x80 + row * 0x40 + col);
}
int output_change_min(void){
	lcd_send_cmd(LINE1);
	lcd_printf("Set minutes");
	output_time_setting();
	return 0;
}
Example #29
0
/*
 * Moves the cursor to the home position.
*/
void
lcd_cursor_home(void)
{
        lcd_load_byte(LCD_CMD_HOME);
        lcd_send_cmd();
}
Example #30
0
void lcd_init_device(void)
{
#if 0
    /* This is the init sequence from the yh820 OF bootloader */
    unsigned long tmp;

    DEV_INIT2 |= 0x400;

    DEV_INIT1 &= ~0x3000;
    tmp = DEV_INIT1;
    DEV_INIT1 = tmp;
    DEV_INIT2 &= ~0x400;

    LCD1_CONTROL &= ~0x4;
    udelay(15);
    LCD1_CONTROL |= 0x4;

    LCD1_CONTROL = 0x680;
    LCD1_CONTROL = 0x684;

    LCD1_CONTROL |= 0x1;

    lcd_send_cmd(LCD_CNTL_RESET);
    lcd_send_cmd(LCD_CNTL_DISCHARGE_ON_OFF | 0);
    lcd_send_cmd(LCD_CNTL_ON_OFF | 0); /* LCD OFF */
    lcd_send_cmd(LCD_CNTL_COLUMN_ADDRESS_DIR | 0);   /* Normal */
    lcd_send_cmd(LCD_CNTL_COMMON_OUTPUT_STATUS | 0); /* Normal */
    lcd_send_cmd(LCD_CNTL_REVERSE | 0); /* Reverse OFF */
    lcd_send_cmd(LCD_CNTL_ALL_LIGHTING | 0); /* Normal */
    lcd_write_reg_ex(LCD_CNTL_DUTY_SET, 0x1f, 0x00);
    lcd_send_cmd(LCD_CNTL_OFF_MODE | 1); /* OFF -> VCC on drivers */
    lcd_write_reg(LCD_CNTL_VOLTAGE_SELECT, 0x03);
    lcd_write_reg(LCD_CNTL_ELECTRONIC_VOLUME, 0x40);
    lcd_write_reg(LCD_CNTL_TEMP_GRADIENT_SELECT, 0x00);
    lcd_write_reg(LCD_CNTL_LINE_INVERT_DRIVE, 0x1f);
    lcd_send_cmd(LCD_CNTL_NLINE_ON_OFF | 1); /* N-line ON */
    lcd_write_reg(LCD_CNTL_OSC_FREQUENCY, 0x00);
    lcd_send_cmd(LCD_CNTL_OSC_ON_OFF | 1); /* Oscillator ON */
    lcd_write_reg(LCD_CNTL_STEPUP_CK_FREQ, 0x03);
    lcd_write_reg(LCD_CNTL_POWER_CONTROL, 0x1c);
    lcd_write_reg(LCD_CNTL_POWER_CONTROL, 0x1e);
    lcd_write_reg(LCD_CNTL_DISPLAY_START_LINE, 0x00);
    lcd_send_cmd(LCD_CNTL_DATA_INPUT_DIR | 0); /* Column mode */
    lcd_send_cmd(LCD_CNTL_DISPLAY_MODE, 0); /* Greyscale mode */
    lcd_write_reg(LCD_CNTL_GRAY_SCALE_PATTERN, 0x52);
    lcd_send_cmd(LCD_CNTL_PARTIAL_DISPLAY_ON_OFF | 0);
    lcd_write_reg(LCD_CNTL_POWER_CONTROL, 0x1f);
    lcd_send_cmd(LCD_CNTL_ON_OFF | 1); /* LCD ON */
#endif
}