Skip to content
Snippets Groups Projects
Select Git revision
  • c13ee1f8fc53f1b71d724de03e5c0c83d4878314
  • master default protected
  • add-utime-unix_time-expansion
  • add-monotonic-time
  • add-digiclk
  • genofire/rockets-state
  • genofire/ble-follow-py
  • plaetzchen/ios-workaround
  • blinkisync-as-preload
  • genofire/haule-ble-fs-deactive
  • schneider/max30001-pycardium
  • schneider/max30001-epicaridum
  • schneider/max30001
  • schneider/stream-locks
  • schneider/fundamental-test
  • schneider/ble-buffers
  • schneider/maxim-sdk-update
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • koalo/wip/i2c-for-python
  • renze/safe_mode
  • v1.9
  • v1.8
  • v1.7
  • v1.6
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
34 results

textbuffer.h

Blame
  • Forked from card10 / firmware
    1401 commits behind, 1 commit ahead of the upstream repository.
    textbuffer.h 1.22 KiB
    #ifndef TEXTBUFFER_H
    #define TEXTBUFFER_H
    #include "gfx.h"
    #include "fonts.h"
    #include <stdint.h>
    
    #define TEXTBUFFER_MAX_WIDTH 40
    #define TEXTBUFFER_MAX_HEIGHT 20
    
    struct txt_glyph {
    	char ch;
    	Color fg_color;
    	Color bg_color;
    };
    
    struct txt_buffer {
    	struct gfx_region *reg;
    	sFONT *font;
    	int cursor_column;
    	int cursor_row;
    	Color fg_color;
    	Color bg_color;
    	int draw_cursor;
    	int auto_update;
    	int needs_redraw;
    
    	struct txt_glyph text[TEXTBUFFER_MAX_HEIGHT][TEXTBUFFER_MAX_WIDTH];
    };
    
    enum txt_color {
    	TEXT_FOREGROUND,
    	TEXT_BACKGROUND
    };
    
    void txt_init(struct txt_buffer *txtb, struct gfx_region *reg, sFONT *f);
    size_t txt_width(struct txt_buffer *tm);
    size_t txt_height(struct txt_buffer *tm);
    void txt_clear(struct txt_buffer *tm);
    void txt_putchar(struct txt_buffer *tm, char ch);
    void txt_puts(struct txt_buffer *tm, const char *str);
    void txt_draw(struct txt_buffer *tm);
    void txt_set_color_f(struct txt_buffer *tm, enum txt_color sw, float r, float g,
    								     float b);
    void txt_set_color(struct txt_buffer *tm, enum txt_color sw, int r, int g,
    								 int b);
    void txt_set_transparent(struct txt_buffer *tm);
    void txt_set_cursor(struct txt_buffer *tm, int x, int y, int draw_cursor);
    void txt_update(struct txt_buffer *tm);
    
    #endif