Skip to content

update BigClock.h with easier 2D array addressing #2

Description

@alifeee

I'm not fully sure why this is needed, as I adopted the library with the patch already applied.

I think it is something to do with making the screen addressable as a 2D array, rather than two arrays.

The new library is here: https://github.com/sheffieldhackspace/train-signs/blob/main/lib/BigClock/BigClock.cpp

The old library (in this repository) is here: https://github.com/daniel1111/BigClockSnake/blob/master/libraries/BigClock/BigClock.cpp

The diff is:

diff --git a/clockold.txt b/clocknew.txt
index 85abb61..aa05534 100644
--- a/clockold.txt
+++ b/clocknew.txt
@@ -123,6 +123,7 @@ void BigClock::flush_sbit()
   }
 }
 
+#define FB_SEQUENTIAL
 
 bool BigClock::get_bit(byte *fb, int x, int y)
 /* x = 0-95
@@ -134,8 +135,12 @@ bool BigClock::get_bit(byte *fb, int x, int y)
     x = 95 - x;  
     y = 12 - y;
   }
-  
+#ifdef FB_SEQUENTIAL
+  y = 25 - y;
+  return *(fb+(y*MAX_X)+(x/8)) >> (7-(x%8)) & 1;
+#else
   return fb[((x/8)*MAX_Y) + y]  & (1 << (x%8));
+#endif
 }
 
 void BigClock::output_segment(int board, byte *framebuf, bool odd_lines, int segment, int row_start, bool tst) // output 6x13 segment (0-7)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions