Make wulfnors st7565 configurable from config file, so it also works with the mini...
[clinton/Smoothieware.git] / src / modules / utils / panel / panels / ST7565.h
CommitLineData
5b8a7abb 1/*
2 * ST7565.h
3 *
4 * Created on: 21-06-2013
5 * Author: Wulfnor
6 */
7
8#ifndef ST7565_H_
9#define ST7565_H_
10#include "LcdBase.h"
11#include "libs/Kernel.h"
12#include "mbed.h"
13#include "libs/Pin.h"
14#include "Panel.h"
15
16using namespace std;
17#include <vector>
18#include <string>
19#include <cstdio>
20#include <cstdarg>
21
22//definitions for lcd
23#define LCDWIDTH 128
24#define LCDHEIGHT 64
25#define LCDPAGES (LCDHEIGHT+7)/8
26#define FB_SIZE LCDWIDTH*LCDPAGES
27#define FONT_SIZE_X 6
28#define FONT_SIZE_Y 8
5b8a7abb 29
3aeb7c2a
JM
30#define spi_channel_checksum CHECKSUM("spi_channel")
31#define spi_cs_pin_checksum CHECKSUM("spi_cs_pin")
5b8a7abb 32#define spi_frequency_checksum CHECKSUM("spi_frequency")
3aeb7c2a
JM
33#define encoder_a_pin_checksum CHECKSUM("encoder_a_pin")
34#define encoder_b_pin_checksum CHECKSUM("encoder_b_pin")
5b8a7abb 35#define click_button_pin_checksum CHECKSUM("click_button_pin")
36#define up_button_pin_checksum CHECKSUM("up_button_pin")
37#define down_button_pin_checksum CHECKSUM("down_button_pin")
3aeb7c2a
JM
38#define contrast_checksum CHECKSUM("contrast")
39#define rst_pin_checksum CHECKSUM("rst_pin")
40#define a0_pin_checksum CHECKSUM("a0_pin")
41
5b8a7abb 42class Panel;
43
44class ST7565: public LcdBase {
45public:
46 ST7565();
47 virtual ~ST7565();
48 void home();
49 void clear();
50 void display();
51 void setCursor(uint8_t col, uint8_t row);
52 void init();
53 void write_char(char value);
54 void write(const char* line, int len);
55
56 void on_refresh(bool now=false);
57 //encoder which dosent exist :/
58 uint8_t readButtons();
59 int readEncoderDelta();
60 int getEncoderResolution() { return 2; }
61 uint16_t get_screen_lines() { return 8; }
62 bool hasGraphics() { return true; }
63
64 //added ST7565 commands
65 void send_commands(const unsigned char* buf, size_t size);
66 void send_data(const unsigned char* buf, size_t size);
67 // set column and page number
68 void set_xy(int x, int y);
69 //send pic to whole screen
70 void send_pic(const unsigned char* data);
71 //drawing char
72 int drawChar(int x, int y, unsigned char c, int color);
73 // blit a glyph of w pixels wide and h pixels high to x, y. offset pixel position in glyph by x_offset, y_offset.
74 // span is the width in bytes of the src bitmap
75 // The glyph bytes will be 8 bits of X pixels, msbit->lsbit from top left to bottom right
76 void bltGlyph(int x, int y, int w, int h, const uint8_t *glyph, int span= 0, int x_offset=0, int y_offset=0);
77 void renderGlyph(int x, int y, const uint8_t *g, int pixelWidth, int pixelHeight);
78 void pixel(int x, int y, int colour);
79
80private:
81 //buffer
82 unsigned char *framebuffer;
83 mbed::SPI* spi;
84 Pin cs;
85 Pin rst;
86 Pin a0;
87 Pin click_pin;
88 Pin up_pin;
89 Pin down_pin;
3aeb7c2a
JM
90 Pin encoder_a_pin;
91 Pin encoder_b_pin;
92
5b8a7abb 93 // text cursor position
94 uint8_t tx, ty;
3aeb7c2a 95 uint8_t contrast;
5b8a7abb 96};
97
98#endif /* ST7565_H_ */