|
|
@ -47,79 +47,80 @@
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 303
|
|
|
|
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 303
|
|
|
|
#error "This library requires AVR-GCC 3.3 or later, update to newer AVR-GCC compiler !"
|
|
|
|
#error "This library requires AVR-GCC 3.3 or later, update to newer AVR-GCC compiler !"
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <avr/pgmspace.h>
|
|
|
|
#include <avr/pgmspace.h>
|
|
|
|
#include "i2c.h" // library for I2C-communication
|
|
|
|
#include "i2c.h" // library for I2C-communication
|
|
|
|
// if you want to use other lib for I2C
|
|
|
|
// if you want to use other lib for I2C
|
|
|
|
// edit i2c_xxx commands in this library
|
|
|
|
// edit i2c_xxx commands in this library
|
|
|
|
// i2c_start(), i2c_byte(), i2c_stop()
|
|
|
|
// i2c_start(), i2c_byte(), i2c_stop()
|
|
|
|
|
|
|
|
/* TODO: define charmode for big chars (double heigth, double width)
|
|
|
|
/* TODO: define displaycontroller */
|
|
|
|
//#define BIGCHAR // uncomment for big chars on display
|
|
|
|
#define SH1106 // or SSD1306, check datasheet of your display
|
|
|
|
/* TODO: define displaycontroller */
|
|
|
|
/* TODO: define displaymode */
|
|
|
|
#define SH1106 // or SSD1306, check datasheet of your display
|
|
|
|
#define TEXTMODE // TEXTMODE for only text to display,
|
|
|
|
/* TODO: define displaymode */
|
|
|
|
// GRAPHICMODE for text and graphic
|
|
|
|
#define TEXTMODE // TEXTMODE for only text to display,
|
|
|
|
/* TODO: define font */
|
|
|
|
// GRAPHICMODE for text and graphic
|
|
|
|
#define FONT ssd1306oled_font// set font here, refer font-name at font.h/font.c
|
|
|
|
/* TODO: define font */
|
|
|
|
|
|
|
|
#define FONT ssd1306oled_font// set font here, refer font-name at font.h/font.c
|
|
|
|
/* TODO: define I2C-adress for display */
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: define I2C-adress for display */
|
|
|
|
// using 7-bit-adress for lcd-library
|
|
|
|
|
|
|
|
// if you use your own library for twi check I2C-adress-handle
|
|
|
|
// using 7-bit-adress for lcd-library
|
|
|
|
#define LCD_I2C_ADR (0x7a >> 1) // 7 bit slave-adress without r/w-bit
|
|
|
|
// if you use your own library for twi check I2C-adress-handle
|
|
|
|
// r/w-bit are set/unset by library
|
|
|
|
#define LCD_I2C_ADR (0x7a >> 1) // 7 bit slave-adress without r/w-bit
|
|
|
|
// e.g. 8 bit slave-adress:
|
|
|
|
// r/w-bit are set/unset by library
|
|
|
|
// 0x78 = adress 0x3C with cleared r/w-bit (write-mode)
|
|
|
|
// e.g. 8 bit slave-adress:
|
|
|
|
|
|
|
|
// 0x78 = adress 0x3C with cleared r/w-bit (write-mode)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef YES
|
|
|
|
#ifndef YES
|
|
|
|
#define YES 1
|
|
|
|
#define YES 1
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#define LCD_DISP_OFF 0xAE
|
|
|
|
#define LCD_DISP_OFF 0xAE
|
|
|
|
#define LCD_DISP_ON 0xAF
|
|
|
|
#define LCD_DISP_ON 0xAF
|
|
|
|
|
|
|
|
|
|
|
|
#define WHITE 0x01
|
|
|
|
#define WHITE 0x01
|
|
|
|
#define BLACK 0x00
|
|
|
|
#define BLACK 0x00
|
|
|
|
|
|
|
|
|
|
|
|
#define DISPLAY_WIDTH 128
|
|
|
|
#define DISPLAY_WIDTH 128
|
|
|
|
#define DISPLAY_HEIGHT 64
|
|
|
|
#define DISPLAY_HEIGHT 64
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void lcd_command(uint8_t cmd[], uint8_t size); // transmit command to display
|
|
|
|
void lcd_command(uint8_t cmd[], uint8_t size); // transmit command to display
|
|
|
|
void lcd_data(uint8_t data[], uint16_t size); // transmit data to display
|
|
|
|
void lcd_data(uint8_t data[], uint16_t size); // transmit data to display
|
|
|
|
void lcd_init(uint8_t dispAttr);
|
|
|
|
void lcd_init(uint8_t dispAttr);
|
|
|
|
void lcd_home(void); // set cursor to 0,0
|
|
|
|
void lcd_home(void); // set cursor to 0,0
|
|
|
|
void lcd_invert(uint8_t invert); // invert display
|
|
|
|
void lcd_invert(uint8_t invert); // invert display
|
|
|
|
void lcd_sleep(uint8_t sleep); // display goto sleep (power off)
|
|
|
|
void lcd_sleep(uint8_t sleep); // display goto sleep (power off)
|
|
|
|
void lcd_set_contrast(uint8_t contrast); // set contrast for display
|
|
|
|
void lcd_set_contrast(uint8_t contrast); // set contrast for display
|
|
|
|
void lcd_puts(const char* s); // print string, \n-terminated, from ram on screen (TEXTMODE)
|
|
|
|
void lcd_puts(const char* s); // print string, \n-terminated, from ram on screen (TEXTMODE)
|
|
|
|
// or buffer (GRAPHICMODE)
|
|
|
|
// or buffer (GRAPHICMODE)
|
|
|
|
void lcd_puts_p(const char* progmem_s); // print string from flash on screen (TEXTMODE)
|
|
|
|
void lcd_puts_p(const char* progmem_s); // print string from flash on screen (TEXTMODE)
|
|
|
|
// or buffer (GRAPHICMODE)
|
|
|
|
// or buffer (GRAPHICMODE)
|
|
|
|
|
|
|
|
|
|
|
|
void lcd_clrscr(void); // clear screen (and buffer at GRFAICMODE)
|
|
|
|
void lcd_clrscr(void); // clear screen (and buffer at GRFAICMODE)
|
|
|
|
void lcd_gotoxy(uint8_t x, uint8_t y); // set curser at pos x, y. x means character,
|
|
|
|
void lcd_gotoxy(uint8_t x, uint8_t y); // set curser at pos x, y. x means character,
|
|
|
|
// y means line (page, refer lcd manual)
|
|
|
|
// y means line (page, refer lcd manual)
|
|
|
|
void lcd_putc(char c); // print character on screen at TEXTMODE
|
|
|
|
void lcd_putc(char c); // print character on screen at TEXTMODE
|
|
|
|
// at GRAPHICMODE print character to buffer
|
|
|
|
// at GRAPHICMODE print character to buffer
|
|
|
|
#if defined GRAPHICMODE
|
|
|
|
#if defined GRAPHICMODE
|
|
|
|
void lcd_drawPixel(uint8_t x, uint8_t y, uint8_t color);
|
|
|
|
void lcd_drawPixel(uint8_t x, uint8_t y, uint8_t color);
|
|
|
|
void lcd_drawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color);
|
|
|
|
void lcd_drawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color);
|
|
|
|
void lcd_drawRect(uint8_t px1, uint8_t py1, uint8_t px2, uint8_t py2, uint8_t color);
|
|
|
|
void lcd_drawRect(uint8_t px1, uint8_t py1, uint8_t px2, uint8_t py2, uint8_t color);
|
|
|
|
void lcd_fillRect(uint8_t px1, uint8_t py1, uint8_t px2, uint8_t py2, uint8_t color);
|
|
|
|
void lcd_fillRect(uint8_t px1, uint8_t py1, uint8_t px2, uint8_t py2, uint8_t color);
|
|
|
|
void lcd_drawCircle(uint8_t center_x, uint8_t center_y, uint8_t radius, uint8_t color);
|
|
|
|
void lcd_drawCircle(uint8_t center_x, uint8_t center_y, uint8_t radius, uint8_t color);
|
|
|
|
void lcd_fillCircle(uint8_t center_x, uint8_t center_y, uint8_t radius, uint8_t color);
|
|
|
|
void lcd_fillCircle(uint8_t center_x, uint8_t center_y, uint8_t radius, uint8_t color);
|
|
|
|
void lcd_drawBitmap(uint8_t x, uint8_t y, const uint8_t picture[], uint8_t width, uint8_t height, uint8_t color);
|
|
|
|
void lcd_drawBitmap(uint8_t x, uint8_t y, const uint8_t picture[], uint8_t width, uint8_t height, uint8_t color);
|
|
|
|
void lcd_display(void); // copy buffer to display RAM
|
|
|
|
void lcd_display(void); // copy buffer to display RAM
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|