Skip to content

Commit

Permalink
Confirmed working for 16x32 panels
Browse files Browse the repository at this point in the history
  • Loading branch information
CamelCaseName committed Nov 30, 2023
1 parent 3819a12 commit dd83149
Show file tree
Hide file tree
Showing 13 changed files with 398 additions and 70 deletions.
48 changes: 17 additions & 31 deletions src/HUB75nano.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,7 @@
#define HUB75NANO_MAIN_H
#include <Arduino.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
#include "Settings.h"

#pragma region definitions

Expand All @@ -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 )
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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"
};
Expand Down
37 changes: 37 additions & 0 deletions src/Settings.h
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions src/boards/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 46 additions & 3 deletions src/boards/every/every_methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand All @@ -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
69 changes: 60 additions & 9 deletions src/boards/iot/iot_methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -43,25 +45,74 @@ __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;
// 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 > 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
Loading

0 comments on commit dd83149

Please sign in to comment.