Skip to content

Commit

Permalink
Add 1bitcolor and many other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
board707 committed Jul 19, 2021
1 parent fd7fef0 commit 20a3b79
Show file tree
Hide file tree
Showing 10 changed files with 1,135 additions and 399 deletions.
7 changes: 7 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# ChangeLog

## Unreleased
## [0.6.3] - 2021-07-18
- Add 1-bit RGB color depth
- Rewrite marquee text code
- Many other changes as ZigZag connect scheme etc

## [0.5.1] - 2021-05-26
- Minor fix

## [0.5.0] - 2021-05-18
New develop branch.
Expand Down
4 changes: 3 additions & 1 deletion DMD_Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ uint8_t DMD_GFX_Font::get_char_width(unsigned char c, byte orientation) {

GFXglyph *glyph = &(((GFXglyph *)pgm_read_pointer(&gfxFont_ptr->glyph))[c]);
if (orientation) {
return (uint8_t)(fontHeight + pgm_read_byte(&glyph->yOffset) + pgm_read_byte(&glyph->height) );
int8_t char_w = fontHeight + (int8_t)pgm_read_byte(&glyph->yOffset) + pgm_read_byte(&glyph->height) ;
if (char_w < 0) return 0;
else return (uint8_t)char_w;
}
else { return (uint8_t)pgm_read_byte(&glyph->xAdvance);}
}
Expand Down
53 changes: 28 additions & 25 deletions DMD_Font.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,33 @@
#pragma once
#include <Arduino.h>
#include "gfxfont.h"


#ifndef pgm_read_byte
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#endif
#ifndef pgm_read_word
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#endif
#ifndef pgm_read_dword
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
#endif

// Pointers are a peculiar case...typically 16-bit on AVR boards,
// 32 bits elsewhere. Try to accommodate both...

#if !defined(__INT_MAX__) || (__INT_MAX__ > 0xFFFF)
#define pgm_read_pointer(addr) ((void *)pgm_read_dword(addr))
#else
#define pgm_read_pointer(addr) ((void *)pgm_read_word(addr))
#include "stm_int.h"

#ifndef pgm_read_byte
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#endif
#ifndef pgm_read_word
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#endif
#ifndef pgm_read_dword
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
#endif

// Pointers are a peculiar case...typically 16-bit on AVR boards,
// 32 bits elsewhere. Try to accommodate both...

#if !defined(__INT_MAX__) || (__INT_MAX__ > 0xFFFF)
#define pgm_read_pointer(addr) ((void *)pgm_read_dword(addr))
#else
#define pgm_read_pointer(addr) ((void *)pgm_read_word(addr))
#endif

// Font Indices
#define FONT_LENGTH 0
#define FONT_FIXED_WIDTH 2
#define FONT_HEIGHT 3
#define FONT_FIRST_CHAR 4
#define FONT_CHAR_COUNT 5
// Font Indices
#define FONT_LENGTH 0
#define FONT_FIXED_WIDTH 2
#define FONT_HEIGHT 3
#define FONT_FIRST_CHAR 4
#define FONT_CHAR_COUNT 5
#define FONT_WIDTH_TABLE 6

class DMD_Font
Expand All @@ -70,6 +70,7 @@ class DMD_Font
virtual bool is_char_in(unsigned char c) = 0;

virtual uint8_t get_char_width(unsigned char c, byte orientation = 0) = 0;

};
/******************************************************/
class DMD_Standard_Font : public DMD_Font {
Expand All @@ -81,6 +82,7 @@ class DMD_Standard_Font : public DMD_Font {
uint8_t get_char_width(unsigned char c, byte orientation =0 );
uint16_t get_bitmap_index(unsigned char c);
bool is_mono_font();

};
/******************************************************/
class DMD_GFX_Font : public DMD_Font {
Expand All @@ -97,6 +99,7 @@ class DMD_GFX_Font : public DMD_Font {
uint8_t lastChar2;
bool is_char_in(unsigned char c);
uint8_t get_char_width(unsigned char c, byte orientation = 0);

void add_second_font(GFXfont* second, uint8_t start_code);
uint8_t get_first_by_char(unsigned char c);
GFXfont* get_font_by_char(unsigned char c);
Expand Down
Loading

0 comments on commit 20a3b79

Please sign in to comment.