Renesas GR-Peach LCD Interface
Dependencies: EthernetInterface HTTPD PubNub SDFileSystem mbed-rtos mbed picojson
Renesas GR-Peach LCD Interface
gen_helper.h@0:0b32d3eaabfe, 2015-10-23 (annotated)
- Committer:
- nikhilchaturtvedi
- Date:
- Fri Oct 23 20:16:05 2015 +0000
- Revision:
- 0:0b32d3eaabfe
Renesas LCD Interface
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nikhilchaturtvedi | 0:0b32d3eaabfe | 1 | #ifndef _GEN_HELPER_H_ |
nikhilchaturtvedi | 0:0b32d3eaabfe | 2 | #define _GEN_HELPER_H_ |
nikhilchaturtvedi | 0:0b32d3eaabfe | 3 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 4 | #include "mbed.h" |
nikhilchaturtvedi | 0:0b32d3eaabfe | 5 | #include "SDFileSystem.h" |
nikhilchaturtvedi | 0:0b32d3eaabfe | 6 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 7 | /* Helper class for drawing onto LCD over SPI*/ |
nikhilchaturtvedi | 0:0b32d3eaabfe | 8 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 9 | /*#defines for screen settings and color - based on Adafruit definitions*/ |
nikhilchaturtvedi | 0:0b32d3eaabfe | 10 | #define SW_RESET 0x01 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 11 | #define AWAKE_SLEEPMODE 0x11 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 12 | #define NORMAL_DISP_ON 0x13 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 13 | #define INVOFF 0x20 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 14 | #define DISPLAY_ON 0x29 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 15 | #define COLUMN_ADDR_SET 0x2A |
nikhilchaturtvedi | 0:0b32d3eaabfe | 16 | #define ROW_ADDR_SET 0x2B |
nikhilchaturtvedi | 0:0b32d3eaabfe | 17 | #define WRITE_RAM 0x2C |
nikhilchaturtvedi | 0:0b32d3eaabfe | 18 | #define COLOR_MODE 0x3A |
nikhilchaturtvedi | 0:0b32d3eaabfe | 19 | #define ORIENTATION 0x36 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 20 | #define FRAMERATE_NORMAL 0xB1 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 21 | #define FRAMERATE_IDLE 0xB2 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 22 | #define FRAMERATE_PARTIAL 0xB3 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 23 | #define INVERTED_MODE_OFF 0xB4 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 24 | #define POWER_CONTROL_1 0xC0 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 25 | #define POWER_CONTROL_2 0xC1 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 26 | #define POWER_CONTROL_3 0xC2 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 27 | #define POWER_CONTROL_4 0xC3 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 28 | #define POWER_CONTROL_5 0xC4 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 29 | #define POWER_CONTROL_6 0xC5 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 30 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 31 | //Screen dimensions |
nikhilchaturtvedi | 0:0b32d3eaabfe | 32 | #define SCREEN_HEIGHT 160 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 33 | #define SCREEN_WIDTH 120 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 34 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 35 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 36 | // Color definitions |
nikhilchaturtvedi | 0:0b32d3eaabfe | 37 | #define BLACK 0x0000 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 38 | #define BLUE 0x001F |
nikhilchaturtvedi | 0:0b32d3eaabfe | 39 | #define RED 0xF800 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 40 | #define GREEN 0x07E0 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 41 | #define CYAN 0x07FF |
nikhilchaturtvedi | 0:0b32d3eaabfe | 42 | #define MAGENTA 0xF81F |
nikhilchaturtvedi | 0:0b32d3eaabfe | 43 | #define YELLOW 0xFFE0 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 44 | #define WHITE 0xFFFF |
nikhilchaturtvedi | 0:0b32d3eaabfe | 45 | #define SKYBLUE 0x6AFFD8 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 46 | #define BROWN 0x8B5436 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 47 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 48 | //hardcoded definitions for testing |
nikhilchaturtvedi | 0:0b32d3eaabfe | 49 | #define HOST_IP_ADDR "143.103.6.188" |
nikhilchaturtvedi | 0:0b32d3eaabfe | 50 | #define HOST_GATEWAY "143.103.6.254" |
nikhilchaturtvedi | 0:0b32d3eaabfe | 51 | #define HOST_SUBNET "255.255.255.0" |
nikhilchaturtvedi | 0:0b32d3eaabfe | 52 | #define HOST_PORT 80 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 53 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 54 | class gen_helper |
nikhilchaturtvedi | 0:0b32d3eaabfe | 55 | { |
nikhilchaturtvedi | 0:0b32d3eaabfe | 56 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 57 | public: |
nikhilchaturtvedi | 0:0b32d3eaabfe | 58 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 59 | /* LCD function declarations */ |
nikhilchaturtvedi | 0:0b32d3eaabfe | 60 | int spiwrite(uint8_t c); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 61 | void write_spi_command(uint8_t c); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 62 | void write_spi_data(uint8_t c); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 63 | void draw_pixel(int16_t x, int16_t y, uint16_t color); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 64 | void lcd_init(); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 65 | void fill_rect(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint32_t color); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 66 | void write_rgb(uint32_t color, uint32_t repeat); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 67 | void draw_vertical_line(int16_t x, int16_t y, int16_t h, uint16_t color); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 68 | void draw_horizontal_line(int16_t x, int16_t y, int16_t w, uint16_t color); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 69 | void set_screen_coor(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 70 | void init_console(); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 71 | void rotate_line(float x1, float y1, float x2, float y2, uint16_t alpha, float *X, float *Y); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 72 | void massaged_line(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, float lambda, uint16_t colour, uint16_t *X, uint16_t *Y); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 73 | void drawLine(int16_t x0, int16_t y0,int16_t x1, int16_t y1,uint16_t color); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 74 | void draw_pattern_helper(); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 75 | void draw_custom_pattern(int x0, int y0, int x1, int y1); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 76 | void draw_pattern(int x1, int y1, int x2, int y2); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 77 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 78 | /* SD card function declarations */ |
nikhilchaturtvedi | 0:0b32d3eaabfe | 79 | uint8_t init_disk(); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 80 | uint8_t make_dir(char *path, uint32_t mode); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 81 | FILE* open_file(char *path, char *mode); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 82 | uint8_t close_file(FILE *fp); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 83 | uint8_t init_SD(); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 84 | uint8_t remove_file(char *path); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 85 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 86 | void decrease_screen_brightness(float); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 87 | void increase_screen_brightness(float); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 88 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 89 | /* CTOR ; Use the list of pins supported at https://developer.mbed.org/teams/Renesas/wiki/GR-PEACH-rev_B-version-information*/ |
nikhilchaturtvedi | 0:0b32d3eaabfe | 90 | gen_helper(PinName MOSI, PinName MISO, PinName SCK, PinName CS, PinName Reset, PinName RS, PinName _USBTX, PinName _USBRX, PwmOut pwm); |
nikhilchaturtvedi | 0:0b32d3eaabfe | 91 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 92 | PwmOut pwm; //Backlite pin. need to be a private member and have get/set functions |
nikhilchaturtvedi | 0:0b32d3eaabfe | 93 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 94 | private: |
nikhilchaturtvedi | 0:0b32d3eaabfe | 95 | SPI lcd; /* SPI0 - MOSI, MISO, SCK P10_14, P10_15, P10_12 */ |
nikhilchaturtvedi | 0:0b32d3eaabfe | 96 | DigitalOut ssel; // Chip select P10_13 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 97 | DigitalOut reset; // Reset signal P3_15 |
nikhilchaturtvedi | 0:0b32d3eaabfe | 98 | DigitalOut rs; // Register select P3_14; Problem with rs pin fixed. |
nikhilchaturtvedi | 0:0b32d3eaabfe | 99 | Serial console; //write to the console using serial comm |
nikhilchaturtvedi | 0:0b32d3eaabfe | 100 | SDFileSystem *sd_fs; //SD card file system instance |
nikhilchaturtvedi | 0:0b32d3eaabfe | 101 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 102 | uint8_t colstart; |
nikhilchaturtvedi | 0:0b32d3eaabfe | 103 | uint8_t rowstart; |
nikhilchaturtvedi | 0:0b32d3eaabfe | 104 | uint8_t _height; //height of the lcd display |
nikhilchaturtvedi | 0:0b32d3eaabfe | 105 | uint8_t _width; //width of the lcd display |
nikhilchaturtvedi | 0:0b32d3eaabfe | 106 | |
nikhilchaturtvedi | 0:0b32d3eaabfe | 107 | }; |
nikhilchaturtvedi | 0:0b32d3eaabfe | 108 | #endif |