From dd83149fcab81215762408659fe9669257392dd9 Mon Sep 17 00:00:00 2001 From: Leonhard Seidel Date: Thu, 30 Nov 2023 21:10:35 +0100 Subject: [PATCH] Confirmed working for 16x32 panels --- src/HUB75nano.h | 48 ++++++--------- src/Settings.h | 37 +++++++++++ src/boards/board.h | 6 ++ src/boards/every/every_methods.h | 49 ++++++++++++++- src/boards/iot/iot_methods.h | 69 ++++++++++++++++++--- src/boards/mega/mega_methods.h | 48 +++++++++++++-- src/boards/method_helper.h | 22 +++++++ src/boards/nano/nano_methods.h | 47 +++++++++++++- src/buffer_setting/2bit_buffer_setting.h | 1 + src/buffer_setting/buffer_common.h | 12 ---- src/output/hub75/1bit_buffer.h | 18 +++++- src/output/hub75/2bit_buffer.h | 33 ++++++++++ src/output/hub75/flash_buffer.h | 78 +++++++++++++++++++++--- 13 files changed, 398 insertions(+), 70 deletions(-) create mode 100644 src/Settings.h create mode 100644 src/boards/method_helper.h diff --git a/src/HUB75nano.h b/src/HUB75nano.h index 32abf56..6cc5d03 100644 --- a/src/HUB75nano.h +++ b/src/HUB75nano.h @@ -18,23 +18,7 @@ #define HUB75NANO_MAIN_H #include -///////////////////// -// #define PANEL_BIG // use 2 bit rgb image buffer -// #define PANEL_FLASH // 4 bit flash buffer -// #define PANEL_NO_BUFFER // no buffer, immediate mode only -// #define PANEL_NO_FONT // disables everything font related, saves some flash -// #define PANEL_MAX_SPEED // aggresively inlines the 4 draw assembly instructions, else its kept as a method to keep size down -// #define PANEL_FLIP_VERTICAL // flips the panel vertically -// #define PANEL_FLIP_HORIZONTAL // flips the panel horizontally -///////////////////// - -// board size (currently max 1 board supported) -#ifndef PANEL_X -#define PANEL_X 64 -#endif -#ifndef PANEL_Y -#define PANEL_Y 32 -#endif +#include "Settings.h" #pragma region definitions @@ -45,24 +29,12 @@ #define PANEL_NO_FONT #endif -// sleep for brightnesses -#ifndef MAX_FRAMETIME -#define MAX_FRAMETIME 127 -#endif - // flash toggle #ifdef PANEL_FLASH #undef PANEL_BIG #ifdef PANEL_FLIP_VERTICAL #error "vertical flip cannot be done on flash output, only horizontal" #endif -// have it bigger a size as we have more available lol -#define PANEL_BUFFERSIZE (PANEL_X * PANEL_Y * 2) // 4 byte per led, we have 6 bit per 2 led per color depth -> about 4k -#endif - -// standard LED struct buffer -#ifndef PANEL_BUFFERSIZE -#define PANEL_BUFFERSIZE (PANEL_X * PANEL_Y / 8) #endif // color transformatuion values (no idea if ) @@ -108,9 +80,15 @@ class Panel buffer = buffer_in; set_pin_output(RA); set_pin_output(RB); +#if PANEL_Y > 8 set_pin_output(RC); +#endif +#if PANEL_Y > 16 set_pin_output(RD); - // set_pin_output(RE); +#endif +#if PANEL_Y > 32 + set_pin_output(RE); +#endif set_pin_output(RF); set_pin_output(RS); set_pin_output(GF); @@ -126,9 +104,15 @@ class Panel { set_pin_output(RA); set_pin_output(RB); +#if PANEL_Y > 8 set_pin_output(RC); +#endif +#if PANEL_Y > 16 set_pin_output(RD); - // set_pin_output(RE); +#endif +#if PANEL_Y > 32 + set_pin_output(RE); +#endif set_pin_output(RF); set_pin_output(RS); set_pin_output(GF); @@ -169,8 +153,10 @@ class Panel #ifndef PANEL_NO_BUFFER #include "buffer_setting/buffer.h" // include drawing code if we want it +#ifndef PANEL_FLASH #include "drawing/drawing.h" #endif +#endif #include "output/output.h" }; diff --git a/src/Settings.h b/src/Settings.h new file mode 100644 index 0000000..c9e047a --- /dev/null +++ b/src/Settings.h @@ -0,0 +1,37 @@ + +#ifndef PANEL_SETTINGS_H +#define PANEL_SETTINGS_H +///////////////////// +// #define PANEL_BIG // use 2 bit rgb image buffer +// #define PANEL_FLASH // 4 bit flash buffer +// #define PANEL_NO_BUFFER // no buffer, immediate mode only +// #define PANEL_NO_FONT // disables everything font related, saves some flash +// #define PANEL_MAX_SPEED // aggresively inlines the 4 draw assembly instructions, else its kept as a method to keep size down +// #define PANEL_FLIP_VERTICAL // flips the panel vertically +// #define PANEL_FLIP_HORIZONTAL // flips the panel horizontally +///////////////////// + +// board size (currently max 1 board supported) +#ifndef PANEL_X +#define PANEL_X 64 +#endif +#ifndef PANEL_Y +#define PANEL_Y 32 +#endif + +// sleep for brightnesses +#ifndef MAX_FRAMETIME +#define MAX_FRAMETIME 127 +#endif + +#ifdef PANEL_FLASH +// have it bigger a size as we have more available lol +#define PANEL_BUFFERSIZE (PANEL_X * PANEL_Y * 2) // 4 byte per led, we have 6 bit per 2 led per color depth -> about 4k +#endif + +// standard LED struct buffer +#ifndef PANEL_BUFFERSIZE +#define PANEL_BUFFERSIZE (PANEL_X * PANEL_Y / 8) +#endif + +#endif // PANEL_SETTINGS_H \ No newline at end of file diff --git a/src/boards/board.h b/src/boards/board.h index a473dd5..acce83a 100644 --- a/src/boards/board.h +++ b/src/boards/board.h @@ -82,16 +82,22 @@ #ifndef RB #error "this needs to be set for the selected board first" #endif +#if PANEL_Y > 8 #ifndef RC #error "this needs to be set for the selected board first" #endif +#endif +#if PANEL_Y > 16 #ifndef RD #error "this needs to be set for the selected board first" #endif +#endif // currently unused +#if PANEL_Y > 32 #ifndef RE #error "this needs to be set for the selected board first" #endif +#endif #ifndef RF #error "this needs to be set for the selected board first" #endif diff --git a/src/boards/every/every_methods.h b/src/boards/every/every_methods.h index 275d9ff..26f0579 100644 --- a/src/boards/every/every_methods.h +++ b/src/boards/every/every_methods.h @@ -3,6 +3,8 @@ #include "every.h" #include "every_pin_helpers.h" +#include "../method_helper.h" +#include "../../Settings.h" // bulk pin access color, only good if pins are in right order #ifdef PANEL_MAX_SPEED @@ -57,12 +59,43 @@ __attribute__((always_inline)) inline void _stepRow() { - +// row pin check +#if PANEL_Y > 32 +#if RA == 11 and RB == 12 and RC == 13 and RD == 8 and RE == 2 + ((PORT_t *)&PORTA + PORTE_OFFSET)->OUTSET = PANEL_ROW_VAR; + ((PORT_t *)&PORTA + PORTE_OFFSET)->OUTCLR = (~PANEL_ROW_VAR) & 31; +#else +#define PANEL_ROW_PINS_OOO +#endif +#else +#if PANEL_Y > 16 #if RA == 11 and RB == 12 and RC == 13 and RD == 8 - // set the 4 _row pins at once ((PORT_t *)&PORTA + PORTE_OFFSET)->OUTSET = PANEL_ROW_VAR; ((PORT_t *)&PORTA + PORTE_OFFSET)->OUTCLR = (~PANEL_ROW_VAR) & 15; #else +#define PANEL_ROW_PINS_OOO +#endif +#else +#if PANEL_Y > 8 +#if RA == 11 and RB == 12 and RC == 13 + ((PORT_t *)&PORTA + PORTE_OFFSET)->OUTSET = PANEL_ROW_VAR; + ((PORT_t *)&PORTA + PORTE_OFFSET)->OUTCLR = (~PANEL_ROW_VAR) & 7; +#else +#define PANEL_ROW_PINS_OOO +#endif +#else +#if PANEL_Y > 4 +#if RA == 11 and RB == 12 + ((PORT_t *)&PORTA + PORTE_OFFSET)->OUTSET = PANEL_ROW_VAR; + ((PORT_t *)&PORTA + PORTE_OFFSET)->OUTCLR = (~PANEL_ROW_VAR) & 3; +#else +#define PANEL_ROW_PINS_OOO +#endif +#endif +#endif +#endif +#endif +#ifdef PANEL_ROW_PINS_OOO __asm__ __volatile__("sbrc %0, 0" ::"r"(PANEL_ROW_VAR)); high_pin(RA); __asm__ __volatile__("sbrs %0, 0" ::"r"(PANEL_ROW_VAR)); @@ -71,16 +104,26 @@ _stepRow() high_pin(RB); __asm__ __volatile__("sbrs %0, 1" ::"r"(PANEL_ROW_VAR)); clear_pin(RB); +#if PANEL_Y > 8 __asm__ __volatile__("sbrc %0, 2" ::"r"(PANEL_ROW_VAR)); high_pin(RC); __asm__ __volatile__("sbrs %0, 2" ::"r"(PANEL_ROW_VAR)); clear_pin(RC); +#endif +#if PANEL_Y > 16 __asm__ __volatile__("sbrc %0, 3" ::"r"(PANEL_ROW_VAR)); high_pin(RD); __asm__ __volatile__("sbrs %0, 3" ::"r"(PANEL_ROW_VAR)); clear_pin(RD); #endif - PANEL_ROW_VAR = (PANEL_ROW_VAR + 1) & (uint8_t)15; +#if PANEL_Y > 32 + __asm__ __volatile__("sbrc %0, 4" ::"r"(PANEL_ROW_VAR)); + high_pin(RE); + __asm__ __volatile__("sbrs %0, 4" ::"r"(PANEL_ROW_VAR)); + clear_pin(RE); +#endif +#endif + PANEL_ADVANCE_ROW; } #endif // HUB75NANO_EVERY_METHODS_H diff --git a/src/boards/iot/iot_methods.h b/src/boards/iot/iot_methods.h index ebc14b5..243b7b9 100644 --- a/src/boards/iot/iot_methods.h +++ b/src/boards/iot/iot_methods.h @@ -2,6 +2,8 @@ #define HUB75NANO_IOT_METHODS_H #include "iot.h" +#include "../method_helper.h" +#include "../../Settings.h" // bulk pin access color, only good if pins are in right order #ifdef PANEL_MAX_SPEED @@ -43,7 +45,19 @@ __attribute__((always_inline)) inline void _stepRow() { - +// row pin check +#if PANEL_Y > 32 +#if RA == A0 and RB == 6 and RC == 5 and RD == 7 and RE == 4 + uint8_t adjustedRow = (PANEL_ROW_VAR & 1) | ((PANEL_ROW_VAR & 30) << 1); + uint8_t invertedRow = (~adjustedRow) & 61; + // set the 4 _row pins at once + PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RA))].OUTSET.reg = adjustedRow << bit_from_pin(arduino_pin_to_avr_pin(RA)); + PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RA))].OUTCLR.reg = invertedRow << bit_from_pin(arduino_pin_to_avr_pin(RA)); +#else +#define PANEL_ROW_PINS_OOO +#endif +#else +#if PANEL_Y > 16 #if RA == A0 and RB == 6 and RC == 5 and RD == 7 uint8_t adjustedRow = (PANEL_ROW_VAR & 1) | ((PANEL_ROW_VAR & 14) << 1); uint8_t invertedRow = (~adjustedRow) & 29; @@ -51,17 +65,54 @@ _stepRow() PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RA))].OUTSET.reg = adjustedRow << bit_from_pin(arduino_pin_to_avr_pin(RA)); PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RA))].OUTCLR.reg = invertedRow << bit_from_pin(arduino_pin_to_avr_pin(RA)); #else +#define PANEL_ROW_PINS_OOO +#endif +#else +#if PANEL_Y > 8 +#if RA == A0 and RB == 6 and RC == 5 + uint8_t adjustedRow = (PANEL_ROW_VAR & 1) | ((PANEL_ROW_VAR & 6) << 1); + uint8_t invertedRow = (~adjustedRow) & 9; + // set the 4 _row pins at once + PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RA))].OUTSET.reg = adjustedRow << bit_from_pin(arduino_pin_to_avr_pin(RA)); + PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RA))].OUTCLR.reg = invertedRow << bit_from_pin(arduino_pin_to_avr_pin(RA)); +#else +#define PANEL_ROW_PINS_OOO +#endif +#else +#if PANEL_Y > 4 +#if RA == A0 and RB == 6 + uint8_t adjustedRow = (PANEL_ROW_VAR & 1) | ((PANEL_ROW_VAR & 2) << 1); + uint8_t invertedRow = (~adjustedRow) & 5; + // set the 4 _row pins at once + PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RA))].OUTSET.reg = adjustedRow << bit_from_pin(arduino_pin_to_avr_pin(RA)); + PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RA))].OUTCLR.reg = invertedRow << bit_from_pin(arduino_pin_to_avr_pin(RA)); +#else +#define PANEL_ROW_PINS_OOO +#endif +#endif +#endif +#endif +#endif +#ifdef PANEL_ROW_PINS_OOO uint8_t invertedRow = (~PANEL_ROW_VAR) & 15; PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RA))].OUTSET.reg = (PANEL_ROW_VAR & 1) << bit_from_pin(arduino_pin_to_avr_pin(RA)); PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RA))].OUTCLR.reg = (invertedRow & 1) << bit_from_pin(arduino_pin_to_avr_pin(RA)); - PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RB))].OUTSET.reg = ((PANEL_ROW_VAR >> 1) & 1) << bit_from_pin(arduino_pin_to_avr_pin(RB)); - PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RA))].OUTCLR.reg = ((invertedRow >> 3) & 1) << bit_from_pin(arduino_pin_to_avr_pin(RB)); - PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RC))].OUTSET.reg = ((PANEL_ROW_VAR >> 2) & 1) << bit_from_pin(arduino_pin_to_avr_pin(RC)); - PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RA))].OUTCLR.reg = ((invertedRow >> 3) & 1) << bit_from_pin(arduino_pin_to_avr_pin(RC)); - PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RD))].OUTSET.reg = ((PANEL_ROW_VAR >> 3) & 1) << bit_from_pin(arduino_pin_to_avr_pin(RD)); - PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RA))].OUTCLR.reg = ((invertedRow >> 3) & 1) << bit_from_pin(arduino_pin_to_avr_pin(RD)); -#endif - PANEL_ROW_VAR = (PANEL_ROW_VAR + 1) & (uint8_t)15; + PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RB))].OUTSET.reg = (PANEL_ROW_VAR & 1) << bit_from_pin(arduino_pin_to_avr_pin(RB)); + PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RB))].OUTCLR.reg = (invertedRow & 1) << bit_from_pin(arduino_pin_to_avr_pin(RB)); +#if PANEL_Y > 8 + PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RC))].OUTSET.reg = (PANEL_ROW_VAR & 1) << bit_from_pin(arduino_pin_to_avr_pin(RC)); + PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RC))].OUTCLR.reg = (invertedRow & 1) << bit_from_pin(arduino_pin_to_avr_pin(RC)); +#endif +#if PANEL_Y > 16 + PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RD))].OUTSET.reg = (PANEL_ROW_VAR & 1) << bit_from_pin(arduino_pin_to_avr_pin(RD)); + PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RD))].OUTCLR.reg = (invertedRow & 1) << bit_from_pin(arduino_pin_to_avr_pin(RD)); +#endif +#if PANEL_Y > 32 + PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RE))].OUTSET.reg = (PANEL_ROW_VAR & 1) << bit_from_pin(arduino_pin_to_avr_pin(RE)); + PORT->Group[port_from_pin(arduino_pin_to_avr_pin(RE))].OUTCLR.reg = (invertedRow & 1) << bit_from_pin(arduino_pin_to_avr_pin(RE)); +#endif +#endif + PANEL_ADVANCE_ROW; } #endif // HUB75NANO_IOT_METHODS_H \ No newline at end of file diff --git a/src/boards/mega/mega_methods.h b/src/boards/mega/mega_methods.h index 4341039..c31f310 100644 --- a/src/boards/mega/mega_methods.h +++ b/src/boards/mega/mega_methods.h @@ -3,6 +3,8 @@ #include "mega.h" #include "mega_pin_helpers.h" +#include "../method_helper.h" +#include "../../Settings.h" // bulk pin access color, only good if pins are in right order #ifdef PANEL_MAX_SPEED @@ -54,11 +56,39 @@ __attribute__((always_inline)) inline void _stepRow() { - +// row pin check +#if PANEL_Y > 32 +#if RA == 22 and RB == 23 and RC == 24 and RD == 25 and RE == 26 + PORTA = PANEL_ROW_VAR | PORTC & (uint8_t)224; +#else +#define PANEL_ROW_PINS_OOO +#endif +#else +#if PANEL_Y > 16 #if RA == 22 and RB == 23 and RC == 24 and RD == 25 - // set the 4 _row pins at once - PORTA = PANEL_ROW_VAR | (PORTA & (uint8_t)224); + PORTA = PANEL_ROW_VAR | PORTC & (uint8_t)240; +#else +#define PANEL_ROW_PINS_OOO +#endif +#else +#if PANEL_Y > 8 +#if RA == 22 and RB == 23 and RC == 24 + PORTA = PANEL_ROW_VAR | PORTC & (uint8_t)248; +#else +#define PANEL_ROW_PINS_OOO +#endif #else +#if PANEL_Y > 4 +#if RA == 22 and RB == 23 + PORTA = PANEL_ROW_VAR | PORTC & (uint8_t)252; +#else +#define PANEL_ROW_PINS_OOO +#endif +#endif +#endif +#endif +#endif +#ifdef PANEL_ROW_PINS_OOO __asm__ __volatile__("sbrc %0, 0" ::"r"(PANEL_ROW_VAR)); high_pin(RA); __asm__ __volatile__("sbrs %0, 0" ::"r"(PANEL_ROW_VAR)); @@ -67,16 +97,26 @@ _stepRow() high_pin(RB); __asm__ __volatile__("sbrs %0, 1" ::"r"(PANEL_ROW_VAR)); clear_pin(RB); +#if PANEL_Y > 8 __asm__ __volatile__("sbrc %0, 2" ::"r"(PANEL_ROW_VAR)); high_pin(RC); __asm__ __volatile__("sbrs %0, 2" ::"r"(PANEL_ROW_VAR)); clear_pin(RC); +#endif +#if PANEL_Y > 16 __asm__ __volatile__("sbrc %0, 3" ::"r"(PANEL_ROW_VAR)); high_pin(RD); __asm__ __volatile__("sbrs %0, 3" ::"r"(PANEL_ROW_VAR)); clear_pin(RD); #endif - PANEL_ROW_VAR = (PANEL_ROW_VAR + 1) & (uint8_t)15; +#if PANEL_Y > 32 + __asm__ __volatile__("sbrc %0, 4" ::"r"(PANEL_ROW_VAR)); + high_pin(RE); + __asm__ __volatile__("sbrs %0, 4" ::"r"(PANEL_ROW_VAR)); + clear_pin(RE); +#endif +#endif + PANEL_ADVANCE_ROW; } #endif // HUB75NANO_MEGA_METHODS_H diff --git a/src/boards/method_helper.h b/src/boards/method_helper.h new file mode 100644 index 0000000..268136f --- /dev/null +++ b/src/boards/method_helper.h @@ -0,0 +1,22 @@ +#ifndef PANEL_METHOD_HELPER +#define PANEL_METHOD_HELPER + +#include "../Settings.h" + +#if PANEL_Y > 32 +#define PANEL_ADVANCE_ROW PANEL_ROW_VAR = (PANEL_ROW_VAR + 1) & (uint8_t)31; +#else +#if PANEL_Y > 16 +#define PANEL_ADVANCE_ROW PANEL_ROW_VAR = (PANEL_ROW_VAR + 1) & (uint8_t)15; +#else +#if PANEL_Y > 8 +#define PANEL_ADVANCE_ROW PANEL_ROW_VAR = (PANEL_ROW_VAR + 1) & (uint8_t)7; +#else +#if PANEL_Y > 4 +#define PANEL_ADVANCE_ROW PANEL_ROW_VAR = (PANEL_ROW_VAR + 1) & (uint8_t)3; +#endif +#endif +#endif +#endif + +#endif // PANEL_METHOD_HELPER \ No newline at end of file diff --git a/src/boards/nano/nano_methods.h b/src/boards/nano/nano_methods.h index fd8429e..c84d963 100644 --- a/src/boards/nano/nano_methods.h +++ b/src/boards/nano/nano_methods.h @@ -2,6 +2,8 @@ #define HUB75NANO_NANO_METHODS_H #include "nano.h" +#include "../method_helper.h" +#include "../../Settings.h" // bulk pin access color, only good if pins are in right order #ifdef PANEL_MAX_SPEED @@ -54,10 +56,39 @@ inline void _stepRow() { -#if RA == 14 and RB == 15 and RC == 16 and RD == 17 - // set the 4 _row pins at once +// row pin check +#if PANEL_Y > 32 +#if RA == 14 and RB == 15 and RC == 16 and RD == 17 and RE == 18 PORTC = PANEL_ROW_VAR | PORTC & (uint8_t)224; #else +#define PANEL_ROW_PINS_OOO +#endif +#else +#if PANEL_Y > 16 +#if RA == 14 and RB == 15 and RC == 16 and RD == 17 + PORTC = PANEL_ROW_VAR | PORTC & (uint8_t)240; +#else +#define PANEL_ROW_PINS_OOO +#endif +#else +#if PANEL_Y > 8 +#if RA == 14 and RB == 15 and RC == 16 + PORTC = PANEL_ROW_VAR | PORTC & (uint8_t)248; +#else +#define PANEL_ROW_PINS_OOO +#endif +#else +#if PANEL_Y > 4 +#if RA == 14 and RB == 15 + PORTC = PANEL_ROW_VAR | PORTC & (uint8_t)252; +#else +#define PANEL_ROW_PINS_OOO +#endif +#endif +#endif +#endif +#endif +#ifdef PANEL_ROW_PINS_OOO __asm__ __volatile__("sbrc %0, 0" ::"r"(PANEL_ROW_VAR)); high_pin(PORT_RA, PORT_PIN_RA); __asm__ __volatile__("sbrs %0, 0" ::"r"(PANEL_ROW_VAR)); @@ -66,16 +97,26 @@ _stepRow() high_pin(PORT_RB, PORT_PIN_RB); __asm__ __volatile__("sbrs %0, 1" ::"r"(PANEL_ROW_VAR)); clear_pin(PORT_RB, PORT_PIN_RB); +#if PANEL_Y > 8 __asm__ __volatile__("sbrc %0, 2" ::"r"(PANEL_ROW_VAR)); high_pin(PORT_RC, PORT_PIN_RC); __asm__ __volatile__("sbrs %0, 2" ::"r"(PANEL_ROW_VAR)); clear_pin(PORT_RC, PORT_PIN_RC); +#endif +#if PANEL_Y > 16 __asm__ __volatile__("sbrc %0, 3" ::"r"(PANEL_ROW_VAR)); high_pin(PORT_RD, PORT_PIN_RD); __asm__ __volatile__("sbrs %0, 3" ::"r"(PANEL_ROW_VAR)); clear_pin(PORT_RD, PORT_PIN_RD); #endif - PANEL_ROW_VAR = (PANEL_ROW_VAR + 1) & (uint8_t)15; +#if PANEL_Y > 32 + __asm__ __volatile__("sbrc %0, 4" ::"r"(PANEL_ROW_VAR)); + high_pin(PORT_RE, PORT_PIN_RE); + __asm__ __volatile__("sbrs %0, 4" ::"r"(PANEL_ROW_VAR)); + clear_pin(PORT_RE, PORT_PIN_RE); +#endif +#endif + PANEL_ADVANCE_ROW; } #endif // HUB75NANO_NANO_METHODS_H diff --git a/src/buffer_setting/2bit_buffer_setting.h b/src/buffer_setting/2bit_buffer_setting.h index 179e643..7b473ad 100644 --- a/src/buffer_setting/2bit_buffer_setting.h +++ b/src/buffer_setting/2bit_buffer_setting.h @@ -4,6 +4,7 @@ #ifdef PANEL_BIG #include "buffer_common.h" +#include "../Settings.h" void _setBigBuffer(uint8_t x, uint8_t y, Color color) { diff --git a/src/buffer_setting/buffer_common.h b/src/buffer_setting/buffer_common.h index 298ac15..a518c5f 100644 --- a/src/buffer_setting/buffer_common.h +++ b/src/buffer_setting/buffer_common.h @@ -6,18 +6,6 @@ #include "../boards/board.h" #include "../boards/board_methods.h" -#ifndef PANEL_BUFFERSIZE -#define PANEL_BUFFERSIZE 0 -#endif - -#ifndef PANEL_X -#define PANEL_X 0 -#endif - -#ifndef PANEL_Y -#define PANEL_Y 0 -#endif - #pragma region buffer_definition #ifndef PANEL_NO_BUFFER #ifdef PANEL_BIG diff --git a/src/output/hub75/1bit_buffer.h b/src/output/hub75/1bit_buffer.h index e204a78..6c7c74b 100644 --- a/src/output/hub75/1bit_buffer.h +++ b/src/output/hub75/1bit_buffer.h @@ -2,6 +2,7 @@ #define HUB75NANO_1BIT_BUFFER_H #include "../../buffer_setting/buffer_common.h" +#include "../../Settings.h" void _displaySmallBuffer() { @@ -9,7 +10,21 @@ void _displaySmallBuffer() CLEAR_OE; for (uint8_t y = 0; y < PANEL_Y / 2; y++) // 16 rows { +#if PANEL_Y > 32 + index = (LED *)(&buffer) + (y << (uint8_t)5); +#else +#if PANEL_Y > 16 index = (LED *)(&buffer) + (y << (uint8_t)4); +#else +#if PANEL_Y > 8 + index = (LED *)(&buffer) + (y << (uint8_t)3); +#else +#if PANEL_Y > 4 + index = (LED *)(&buffer) + (y << (uint8_t)2); +#endif +#endif +#endif +#endif // we set each pixel after the other _set_color(*(uint8_t *)(index) << (uint8_t)2); @@ -86,7 +101,7 @@ void _displaySmallBuffer() Clock; _set_color((*(((uint8_t *)(index)) + (sizeof(uint8_t) * 2)))); Clock; - +#if PANEL_X > 32 ++index; _set_color(*(uint8_t *)(index) << (uint8_t)2); Clock; @@ -162,6 +177,7 @@ void _displaySmallBuffer() Clock; _set_color((*(((uint8_t *)(index)) + (sizeof(uint8_t) * 2)))); Clock; +#endif // set _row HIGH_OE; LATCH; diff --git a/src/output/hub75/2bit_buffer.h b/src/output/hub75/2bit_buffer.h index 31a5b09..f2945d6 100644 --- a/src/output/hub75/2bit_buffer.h +++ b/src/output/hub75/2bit_buffer.h @@ -3,6 +3,7 @@ #ifdef PANEL_BIG #include "../../buffer_setting/buffer_common.h" +#include "../../Settings.h" void _displayBigBuffer() { @@ -17,7 +18,21 @@ void _displayBigBuffer() for (uint8_t y = 0; y < PANEL_Y / 2; y++) // 16 rows { +#if PANEL_Y > 32 + index = (LED *)(&buffer) + (y << (uint8_t)5); +#else +#if PANEL_Y > 16 index = (LED *)(&buffer) + (y << (uint8_t)4); +#else +#if PANEL_Y > 8 + index = (LED *)(&buffer) + (y << (uint8_t)3); +#else +#if PANEL_Y > 4 + index = (LED *)(&buffer) + (y << (uint8_t)2); +#endif +#endif +#endif +#endif _set_color((uint8_t)((*((uint16_t *)(index)) >> (uint8_t)4))); Clock; @@ -94,6 +109,7 @@ void _displayBigBuffer() _set_color((*(((uint8_t *)(index)) + (sizeof(uint8_t) * 5)))); Clock; +#if PANEL_X > 32 ++index; _set_color((uint8_t)((*((uint16_t *)(index)) >> (uint8_t)4))); Clock; @@ -169,6 +185,7 @@ void _displayBigBuffer() Clock; _set_color((*(((uint8_t *)(index)) + (sizeof(uint8_t) * 5)))); Clock; +#endif // display _row HIGH_OE; LATCH; @@ -185,7 +202,21 @@ void _displayBigBuffer() for (uint8_t y = 0; y < PANEL_Y / 2; y++) { +#if PANEL_Y > 32 + index = (LED *)(&buffer) + (y << (uint8_t)5); +#else +#if PANEL_Y > 16 index = (LED *)(&buffer) + (y << (uint8_t)4); +#else +#if PANEL_Y > 8 + index = (LED *)(&buffer) + (y << (uint8_t)3); +#else +#if PANEL_Y > 4 + index = (LED *)(&buffer) + (y << (uint8_t)2); +#endif +#endif +#endif +#endif _set_color(*(uint8_t *)(index) << (uint8_t)2); Clock; @@ -262,6 +293,7 @@ void _displayBigBuffer() _set_color((uint8_t)((*((uint16_t *)(((uint8_t *)(index)) + (sizeof(uint8_t) * 4)))) >> (uint8_t)2)); Clock; +#if PANEL_X > 32 ++index; _set_color(*(uint8_t *)(index) << (uint8_t)2); Clock; @@ -337,6 +369,7 @@ void _displayBigBuffer() Clock; _set_color((uint8_t)((*((uint16_t *)(((uint8_t *)(index)) + (sizeof(uint8_t) * 4)))) >> (uint8_t)2)); Clock; +#endif // display _row HIGH_OE; LATCH; diff --git a/src/output/hub75/flash_buffer.h b/src/output/hub75/flash_buffer.h index 7ac366e..d0547cc 100644 --- a/src/output/hub75/flash_buffer.h +++ b/src/output/hub75/flash_buffer.h @@ -5,8 +5,9 @@ #include #include "../../buffer_setting/buffer_common.h" +#include "../../Settings.h" -typedef const uint16_t *buffer_t; +typedef const uint8_t *buffer_t; void _displayFlashBuffer() { @@ -16,10 +17,24 @@ void _displayFlashBuffer() #else #define INDEX_MOVE index++ #endif - for (uint8_t y = 0; y < PANEL_Y; y++) // 32 rows + for (uint8_t y = 0; y < PANEL_Y / 2; y++) // 32 rows { // we send first the MMSB, then MSB, LSB, LLSB +#if PANEL_Y > 32 + index = (buffer_t)(buffer + (y << (uint8_t)7)); +#else +#if PANEL_Y > 16 index = (buffer_t)(buffer + (y << (uint8_t)6)); +#else +#if PANEL_Y > 8 + index = (buffer_t)(buffer + (y << (uint8_t)5)); +#else +#if PANEL_Y > 4 + index = (buffer_t)(buffer + (y << (uint8_t)4)); +#endif +#endif +#endif +#endif #ifdef PANEL_FLIP_HORIZONTAL index += PANEL_X; #endif @@ -93,6 +108,7 @@ void _displayFlashBuffer() _set_color(pgm_read_byte(INDEX_MOVE)); Clock; +#if PANEL_X > 32 _set_color(pgm_read_byte(INDEX_MOVE)); Clock; _set_color(pgm_read_byte(INDEX_MOVE)); @@ -160,6 +176,7 @@ void _displayFlashBuffer() Clock; _set_color(pgm_read_byte(index)); Clock; +#endif // shift data into buffers HIGH_OE; LATCH; @@ -173,9 +190,23 @@ void _displayFlashBuffer() } #pragma endregion // MMSB - for (uint8_t y = 0; y < PANEL_Y; y++) // 32 rows + for (uint8_t y = 0; y < PANEL_Y / 2; y++) // 32 rows { +#if PANEL_Y > 32 + index = (buffer_t)(buffer + (y << (uint8_t)7)) + (PANEL_BUFFERSIZE / 4); +#else +#if PANEL_Y > 16 index = (buffer_t)(buffer + (y << (uint8_t)6)) + (PANEL_BUFFERSIZE / 4); +#else +#if PANEL_Y > 8 + index = (buffer_t)(buffer + (y << (uint8_t)5)) + (PANEL_BUFFERSIZE / 4); +#else +#if PANEL_Y > 4 + index = (buffer_t)(buffer + (y << (uint8_t)4)) + (PANEL_BUFFERSIZE / 4); +#endif +#endif +#endif +#endif #ifdef PANEL_FLIP_HORIZONTAL index += PANEL_X; @@ -249,6 +280,7 @@ void _displayFlashBuffer() _set_color(pgm_read_byte(INDEX_MOVE)); Clock; +#if PANEL_X > 32 _set_color(pgm_read_byte(INDEX_MOVE)); Clock; _set_color(pgm_read_byte(INDEX_MOVE)); @@ -316,6 +348,7 @@ void _displayFlashBuffer() Clock; _set_color(pgm_read_byte(index)); Clock; +#endif // shift data into buffers HIGH_OE; LATCH; @@ -329,10 +362,23 @@ void _displayFlashBuffer() } #pragma endregion // MMSB - for (uint8_t y = 0; y < PANEL_Y; y++) // 32 rows + for (uint8_t y = 0; y < PANEL_Y / 2; y++) // 32 rows { +#if PANEL_Y > 32 + index = (buffer_t)(buffer + (y << (uint8_t)7)) + (PANEL_BUFFERSIZE / 2); +#else +#if PANEL_Y > 16 index = (buffer_t)(buffer + (y << (uint8_t)6)) + (PANEL_BUFFERSIZE / 2); - +#else +#if PANEL_Y > 8 + index = (buffer_t)(buffer + (y << (uint8_t)5)) + (PANEL_BUFFERSIZE / 2); +#else +#if PANEL_Y > 4 + index = (buffer_t)(buffer + (y << (uint8_t)4)) + (PANEL_BUFFERSIZE / 2); +#endif +#endif +#endif +#endif #ifdef PANEL_FLIP_HORIZONTAL index += PANEL_X; #endif @@ -405,6 +451,7 @@ void _displayFlashBuffer() _set_color(pgm_read_byte(INDEX_MOVE)); Clock; +#if PANEL_X > 32 _set_color(pgm_read_byte(INDEX_MOVE)); Clock; _set_color(pgm_read_byte(INDEX_MOVE)); @@ -472,6 +519,7 @@ void _displayFlashBuffer() Clock; _set_color(pgm_read_byte(index)); Clock; +#endif // shift data into buffers HIGH_OE; LATCH; @@ -485,9 +533,23 @@ void _displayFlashBuffer() } #pragma endregion // LSB - for (uint8_t y = 0; y < PANEL_Y; y++) // 32 rows + for (uint8_t y = 0; y < PANEL_Y / 2; y++) // 32 rows { - index = (buffer_t)(buffer + (y << (uint8_t)6)) + (PANEL_BUFFERSIZE * 3 / 4); // advance index to next section +#if PANEL_Y > 32 + index = (buffer_t)(buffer + (y << (uint8_t)7)) + (PANEL_BUFFERSIZE * 3 / 4); +#else +#if PANEL_Y > 16 + index = (buffer_t)(buffer + (y << (uint8_t)6)) + (PANEL_BUFFERSIZE * 3 / 4); +#else +#if PANEL_Y > 8 + index = (buffer_t)(buffer + (y << (uint8_t)5)) + (PANEL_BUFFERSIZE * 3 / 4); +#else +#if PANEL_Y > 4 + index = (buffer_t)(buffer + (y << (uint8_t)4)) + (PANEL_BUFFERSIZE * 3 / 4); +#endif +#endif +#endif +#endif #ifdef PANEL_FLIP_HORIZONTAL index += PANEL_X; @@ -561,6 +623,7 @@ void _displayFlashBuffer() _set_color(pgm_read_byte(INDEX_MOVE)); Clock; +#if PANEL_X > 32 _set_color(pgm_read_byte(INDEX_MOVE)); Clock; _set_color(pgm_read_byte(INDEX_MOVE)); @@ -628,6 +691,7 @@ void _displayFlashBuffer() Clock; _set_color(pgm_read_byte(index)); Clock; +#endif // shift data into buffers HIGH_OE; LATCH;