Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit4dccba79d288deafd92e98be31c92e5ad2e0b337 (patch)
Author
 Syndamia <kamen@syndamia.com>
2024-05-22 13:50:52 +0300
Committer
 Syndamia <kamen@syndamia.com>
2024-05-22 13:50:52 +0300
Files963fd7f4b41712a2d82303e443f3f88f0445fee4
uni-projects-4dccba79d288deafd92e98be31c92e5ad2e0b337.tar
uni-projects-4dccba79d288deafd92e98be31c92e5ad2e0b337.tar.gz
uni-projects-4dccba79d288deafd92e98be31c92e5ad2e0b337.zip
Parent194a5454431bb9eb9e3da3165fe138b823be96ee (diff)
(iot/goam) Started working on a flexible printline function
2 files changed, 65 insertions, 35 deletions
-rw-r--r--Year 3/Internet of things/goam/main/display.c97
-rw-r--r--Year 3/Internet of things/goam/main/ibm-vga-8x16.c3
diff --git a/Year 3/Internet of things/goam/main/display.c b/Year 3/Internet of things/goam/main/display.c
index 5c367c3..b63e5a5 100644
--- a/Year 3/Internet of things/goam/main/display.c
+++ b/Year 3/Internet of things/goam/main/display.c
@@ -58,9 +58,9 @@ static void send(enum DATA_TYPE type, const unsigned char* data, size_t size) {
* Public interface
*/
-static const unsigned char startup[] = { 0x8D, 0x14, 0xAF };
+static const unsigned char startup[] = {
+ 0x8D, 0x14, 0xAF,
-const unsigned char pattern[] = {
0x20, // vertical address mode
0b00,
0x21, // set column start/end
@@ -69,10 +69,15 @@ const unsigned char pattern[] = {
0, 7,
};
+unsigned char current_page = 0;
+
+static void incr_page() {
+ current_page = (current_page + 1) % 8;
+}
+
void display_init() {
i2c_init();
- send(CMD_STREAM, startup, 4);
- send(CMD_STREAM, pattern, sizeof(pattern));
+ send(CMD_STREAM, startup, sizeof(startup));
ESP_LOGI(TAG, "Initialized display");
}
@@ -86,17 +91,39 @@ extern const unsigned bitpixel_char_height;
extern const unsigned bitpixel_char_width;
extern const uint8_t* bitpixel_chars[256];
-static const size_t line_width = 16;
+/* static const size_t line_width = 16; */
/* static const size_t lines = 64 / bitpixel_char_height; */
-unsigned char out_str[1 + 16 * 8] = { };
+unsigned char out_page_row[128];
-void display_print(const char* str) {
- int outI = 1;
- for (int pixelRow = 0; pixelRow < bitpixel_char_height; pixelRow++) {
- for (int i = 0; i < line_width; i++) {
- out_str[outI++] = bitpixel_chars[1][pixelRow];
+void display_output_borders(unsigned char column_start, unsigned char column_end, unsigned char page_start, unsigned char page_end) {
+ unsigned char command[] = { 0x21, column_start, column_end, 0x22, page_start, page_end };
+ send(CMD_STREAM, command, sizeof(command));
+}
+
+void display_output_beginning() {
+ display_output_borders(0, 127, 0, 7);
+}
+
+void display_newline() {
+ display_output_borders(0, 127, current_page + 1, 7);
+}
+
+void display_println(const char* str) {
+ for (int linepage = 0; linepage <= 1; linepage++, incr_page()) {
+ int column;
+ for (column = 0; column < 128; column++) {
+ if (str[column / bitpixel_char_width] == '\0') break;
+ /* if (str[column / bitpixel_char_width] == '\n') { */
+ /* str += column / bitpixel_char_width; */
+ /* break; */
+ /* } */
+ out_page_row[column] = bitpixel_chars[(int)str[column / bitpixel_char_width]][(column * 2 + linepage) % 16];
}
+ send(DATA_STREAM, out_page_row, column + 1);
+ /* if (column + 1 < sizeof(out_page_row)) { */
+ /* display_newline(); */
+ /* } */
}
}
@@ -106,29 +133,31 @@ void display_example() {
// MUST be separated, for some reason
/* send(CMD_STREAM, &off, 1); */
/* display_print(""); */
- for (int i = 0; i < 16; i++) {
- out_str[i] = bitpixel_chars[1][(i * 2) % 16];
- }
- send(DATA_STREAM, out_str, 16);
- send(DATA_STREAM, out_str, 16);
- send(DATA_STREAM, out_str, 16);
- send(DATA_STREAM, out_str, 16);
- send(DATA_STREAM, out_str, 16);
- send(DATA_STREAM, out_str, 16);
- send(DATA_STREAM, out_str, 16);
- send(DATA_STREAM, out_str, 16);
- for (int i = 0; i < 16; i++) {
- out_str[i] = bitpixel_chars[1][(i * 2+1) % 16];
- }
- send(DATA_STREAM, out_str, 16);
- send(DATA_STREAM, out_str, 16);
- send(DATA_STREAM, out_str, 16);
- send(DATA_STREAM, out_str, 16);
- send(DATA_STREAM, out_str, 16);
- send(DATA_STREAM, out_str, 16);
- send(DATA_STREAM, out_str, 16);
- send(DATA_STREAM, out_str, 16);
- /* send(out_str, sizeof(out_str)); */
+ display_println("A A A A A A A A A");
+ display_println("AAAAAAAA");
+ /* for (int i = 0; i < 16; i++) { */
+ /* out_page_row[i] = bitpixel_chars[1][(i * 2) % 16]; */
+ /* } */
+ /* send(DATA_STREAM, out_page_row, 16); */
+ /* send(DATA_STREAM, out_page_row, 16); */
+ /* send(DATA_STREAM, out_page_row, 16); */
+ /* send(DATA_STREAM, out_page_row, 16); */
+ /* send(DATA_STREAM, out_page_row, 16); */
+ /* send(DATA_STREAM, out_page_row, 16); */
+ /* send(DATA_STREAM, out_page_row, 16); */
+ /* send(DATA_STREAM, out_page_row, 16); */
+ /* for (int i = 0; i < 16; i++) { */
+ /* out_page_row[i] = bitpixel_chars[1][(i * 2+1) % 16]; */
+ /* } */
+ /* send(DATA_STREAM, out_page_row, 16); */
+ /* send(DATA_STREAM, out_page_row, 16); */
+ /* send(DATA_STREAM, out_page_row, 16); */
+ /* send(DATA_STREAM, out_page_row, 16); */
+ /* send(DATA_STREAM, out_page_row, 16); */
+ /* send(DATA_STREAM, out_page_row, 16); */
+ /* send(DATA_STREAM, out_page_row, 16); */
+ /* send(DATA_STREAM, out_page_row, 16); */
+ /* send(out_page_row, sizeof(out_page_row)); */
/* send(pattern + 8, 3); */
/* send(CMD_STREAM, &on, 1); */
}
diff --git a/Year 3/Internet of things/goam/main/ibm-vga-8x16.c b/Year 3/Internet of things/goam/main/ibm-vga-8x16.c
index 201310e..2bb7922 100644
--- a/Year 3/Internet of things/goam/main/ibm-vga-8x16.c
+++ b/Year 3/Internet of things/goam/main/ibm-vga-8x16.c
@@ -35,5 +35,6 @@ const uint8_t A[16] = {
/* }; */
const uint8_t* bitpixel_chars[256] = {
- space, A
+ ['A'] = A,
+ [' '] = space,
};