Subversion Repositories Tronxy-X3A-Marlin

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ron 1
/**
2
 * Lightweight Status Screen for the RepRapDiscount Full
3
 * Graphics Smart Controller (ST7920-based 128x64 LCD)
4
 *
5
 * (c) 2017 Aleph Objects, Inc.
6
 *
7
 * The code in this page is free software: you can
8
 * redistribute it and/or modify it under the terms of the GNU
9
 * General Public License (GNU GPL) as published by the Free Software
10
 * Foundation, either version 3 of the License, or (at your option)
11
 * any later version.  The code is distributed WITHOUT ANY WARRANTY;
12
 * without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
14
 *
15
 */
16
 
17
#ifndef STATUS_SCREEN_LITE_ST7920_CLASS_H
18
#define STATUS_SCREEN_LITE_ST7920_CLASS_H
19
 
20
#include "macros.h"
21
#include "duration_t.h"
22
 
23
typedef const __FlashStringHelper *progmem_str;
24
 
25
class ST7920_Lite_Status_Screen {
26
  private:
27
    static struct st7920_state_t {
28
      uint8_t synced   : 1; // Whether a sync has been sent
29
      uint8_t cmd      : 1; // Whether the sync was cmd or data
30
      uint8_t extended : 1;
31
      uint8_t graphics : 1;
32
      uint8_t sa       : 1;
33
    } current_bits;
34
 
35
    static void cs();
36
    static void ncs();
37
    static void sync_cmd();
38
    static void sync_dat();
39
    static void write_byte(const uint8_t w);
40
 
41
    FORCE_INLINE static void write_word(const uint16_t w) {
42
      write_byte((w >> 8) & 0xFF);
43
      write_byte((w >> 0) & 0xFF);
44
    }
45
 
46
    static void cmd(const uint8_t cmd);
47
    static void begin_data();
48
 
49
    static void write_str(const char *str);
50
    static void write_str(const char *str, const uint8_t len);
51
    static void write_str_P(const char * const str);
52
    static void write_str(progmem_str str);
53
    static void write_number(const int16_t value, const uint8_t digits=3);
54
 
55
    static void _extended_function_set(const bool extended, const bool graphics);
56
    static void _scroll_or_addr_select(const bool sa);
57
    static void reset_state_from_unknown();
58
 
59
    static void home();
60
    static void display_status(const bool display_on, const bool cursor_on, const bool blink_on);
61
    static void extended_function_set(const bool extended);
62
    static void graphics(const bool graphics);
63
    static void entry_mode_select(const bool ac_increase, const bool shift);
64
    static void scroll_or_addr_select(const bool sa);
65
    static void set_ddram_address(const uint8_t addr);
66
    static void set_cgram_address(const uint8_t addr);
67
    static void set_gdram_address(const uint8_t x, const uint8_t y);
68
 
69
    static void clear();
70
    static void clear_ddram();
71
    static void clear_gdram();
72
 
73
    static void load_cgram_icon(const uint16_t addr, const void *data);
74
    static void draw_gdram_icon(uint8_t x, uint8_t y, const void *data);
75
 
76
    static uint8_t string_checksum(const char *str);
77
 
78
  protected:
79
    static void draw_degree_symbol(uint8_t x, uint8_t y, bool draw);
80
    static void draw_static_elements();
81
    static void draw_progress_bar(const uint8_t value);
82
    static void draw_fan_icon(const bool whichIcon);
83
    static void draw_heat_icon(const bool whichIcon, const bool heating);
84
    static void draw_temps(uint8_t line, const int16_t temp, const int16_t target, bool showTarget, bool targetStateChange);
85
    static void draw_extruder_1_temp(const int16_t temp, const int16_t target, bool forceUpdate = false);
86
    static void draw_extruder_2_temp(const int16_t temp, const int16_t target, bool forceUpdate = false);
87
    static void draw_bed_temp(const int16_t temp, const int16_t target, bool forceUpdate = false);
88
    static void draw_fan_speed(const uint8_t value);
89
    static void draw_print_time(const duration_t &elapsed);
90
    static void draw_feedrate_percentage(const uint8_t percentage);
91
    static void draw_status_message(const char *str);
92
    static void draw_position(const float x, const float y, const float z, bool position_known = true);
93
 
94
    static bool indicators_changed();
95
    static bool position_changed();
96
    static bool blink_changed();
97
    static bool status_changed();
98
 
99
    static void update_indicators(const bool forceUpdate);
100
    static void update_position(const bool forceUpdate, bool resetChecksum);
101
    static void update_status_or_position(bool forceUpdate);
102
    static void update_progress(const bool forceUpdate);
103
 
104
  public:
105
    static void update(const bool forceUpdate);
106
    static void on_entry();
107
    static void on_exit();
108
    static void clear_text_buffer();
109
};
110
 
111
#endif // STATUS_SCREEN_LITE_ST7920_CLASS_H