Skip to content

Commit c1087d4

Browse files
committed
fix set_memory
1 parent 7287b86 commit c1087d4

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

README.MD

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# ST7302-for-arduino
22
- micropython version see [https://github.com/zhcong/ST7302-for-micropython](https://github.com/zhcong/ST7302-for-micropython)
33
- datasheet pdf file see [this link](doc/ST7302_V0.0.pdf)
4+
## screen
5+
![direction](doc/screen.jpg)
46
## screen direction
57
![direction](doc/screen-arrow.png)
68

doc/screen.jpg

67.5 KB
Loading

libraries/ST7302SPI/ST7302SPI.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,14 @@ void ST7302SPI::set_memory(int x_start_byte, int y, int width, int height, uint8
139139
int width_byte_size = int(_width / BYTE_BIT_SIZE);
140140
int part_width_byte_size = int(width / BYTE_BIT_SIZE);
141141
int byte_start = y * width_byte_size + x_start_byte;
142-
for (int i = 0; i != part_width_byte_size; i++) {
143-
for (int j = 0; j != height; j++) {
144-
if (len_i == len) {
145-
return;
142+
for (int i = 0; i != height; i++) {
143+
for (int j = 0; j != part_width_byte_size; j++) {
144+
if (len_i == len) {
145+
return;
146+
}
147+
_buffer[byte_start + i * width_byte_size + j] = data[len_i];
148+
len_i++;
146149
}
147-
_buffer[byte_start + j * width_byte_size + i] = data[len_i];
148-
len_i++;
149-
}
150150
}
151151
}
152152

libraries/ST7302SPI/ST7302SPI.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include <Print.h>
21
#include <SPI.h>
32
#include <Arduino.h>
43

@@ -21,7 +20,7 @@ class ST7302SPI
2120
void send_command(uint8_t command);
2221
void send_param(uint8_t param);
2322
// x_start_byte is byte array start position, not x pixel
24-
void set_memory(int x_start_byte, int y, int width, int height, uint8_t * data, int len) ;
23+
void set_memory(int x_start_byte, int y, int width, int height, uint8_t * data, int len);
2524
void text(int x_start_byte, int y, char words[], int len);
2625

2726
private:

libraries/ST7302SPI/examples/ST7302Hello/ST7302Hello.ino

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#define _PIN_MOSI_ 3
88
#define _PIN_MISO_ -1
99

10+
uint8_t font[]={0x06, 0x00, 0x00, 0x18, 0x07, 0x80, 0x00, 0x3c, 0x03, 0x87, 0xff, 0xfe, 0x03, 0xc0, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x21, 0x80, 0x70, 0x00, 0x71, 0xff, 0xf8, 0x7f, 0xf9, 0xc0, 0x78, 0x00, 0xf9, 0xc0, 0x70, 0x00, 0xf1, 0xc0, 0x70, 0x01, 0xe1, 0xc0, 0x70, 0x01, 0xe1, 0xc0, 0x70, 0x03, 0xc1, 0xff, 0xf0, 0x03, 0x81, 0xc0, 0x70, 0x07, 0xc0, 0x00, 0x10, 0x0f, 0xe6, 0x00, 0x38, 0x0f, 0xf7, 0xff, 0xfe, 0x1f, 0xbf, 0x0e, 0x3c, 0x37, 0xbf, 0x0e, 0x3c, 0x47, 0x87, 0x0e, 0x3c, 0x07, 0x87, 0x0e, 0x3c, 0x07, 0x87, 0xff, 0xfc, 0x07, 0x87, 0x0e, 0x3c, 0x07, 0x87, 0x0e, 0x3c, 0x07, 0x87, 0x0e, 0x3c, 0x07, 0x87, 0x0e, 0x3c, 0x07, 0x87, 0x0e, 0x3c, 0x07, 0x87, 0xff, 0xfc, 0x07, 0x87, 0x00, 0x3c, 0x07, 0x07, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
11+
1012
ST7302SPI st7302spi(_PIN_SCK_, _PIN_MISO_, _PIN_MOSI_, _PIN_RST_, _PIN_DC_, _PIN_CS_, 250, 122);
1113

1214
void setup() {
@@ -18,6 +20,9 @@ void setup() {
1820
// draw ascii
1921
char str1[] = "hello word1.";
2022
st7302spi. text(1, 20, str1, strlen(str1));
23+
24+
st7302spi.set_memory(0, 40, 32, 32, font, 128);
25+
2126
st7302spi.flush_buffer();
2227
}
2328

libraries/ST7302SPI/library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ sentence=LCD screen ST7302 for arduino.
66
paragraph=This driver can draw ascii characters, draw points and write directly to memory, for ST7302 screen driver.
77
category=Display
88
url=https://github.com/zhcong/ST7302-for-arduino
9-
architectures=* includes=ST7302SPI.h
9+
architectures=*

0 commit comments

Comments
 (0)