Add oled_invert (#13172)
Co-authored-by: Drashna Jaelre <drashna@live.com>
This commit is contained in:
		
							parent
							
								
									172e6a7030
								
							
						
					
					
						commit
						0311c8036d
					
				
					 3 changed files with 34 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -34,6 +34,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		|||
#define DISPLAY_ALL_ON 0xA5
 | 
			
		||||
#define DISPLAY_ALL_ON_RESUME 0xA4
 | 
			
		||||
#define NORMAL_DISPLAY 0xA6
 | 
			
		||||
#define INVERT_DISPLAY 0xA7
 | 
			
		||||
#define DISPLAY_ON 0xAF
 | 
			
		||||
#define DISPLAY_OFF 0xAE
 | 
			
		||||
#define NOP 0xE3
 | 
			
		||||
| 
						 | 
				
			
			@ -114,6 +115,7 @@ OLED_BLOCK_TYPE oled_dirty          = 0;
 | 
			
		|||
bool            oled_initialized    = false;
 | 
			
		||||
bool            oled_active         = false;
 | 
			
		||||
bool            oled_scrolling      = false;
 | 
			
		||||
bool            oled_inverted       = false;
 | 
			
		||||
uint8_t         oled_brightness     = OLED_BRIGHTNESS;
 | 
			
		||||
oled_rotation_t oled_rotation       = 0;
 | 
			
		||||
uint8_t         oled_rotation_width = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -690,6 +692,30 @@ bool oled_scroll_off(void) {
 | 
			
		|||
    return !oled_scrolling;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool oled_invert(bool invert) {
 | 
			
		||||
    if (!oled_initialized) {
 | 
			
		||||
        return oled_inverted;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (invert && !oled_inverted) {
 | 
			
		||||
        static const uint8_t PROGMEM display_inverted[] = {I2C_CMD, INVERT_DISPLAY};
 | 
			
		||||
        if (I2C_TRANSMIT_P(display_inverted) != I2C_STATUS_SUCCESS) {
 | 
			
		||||
            print("oled_invert cmd failed\n");
 | 
			
		||||
            return oled_inverted;
 | 
			
		||||
        }
 | 
			
		||||
        oled_inverted = true;
 | 
			
		||||
    } else if (!invert && oled_inverted) {
 | 
			
		||||
        static const uint8_t PROGMEM display_normal[] = {I2C_CMD, NORMAL_DISPLAY};
 | 
			
		||||
        if (I2C_TRANSMIT_P(display_normal) != I2C_STATUS_SUCCESS) {
 | 
			
		||||
            print("oled_invert cmd failed\n");
 | 
			
		||||
            return oled_inverted;
 | 
			
		||||
        }
 | 
			
		||||
        oled_inverted = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return oled_inverted;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t oled_max_chars(void) {
 | 
			
		||||
    if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
 | 
			
		||||
        return OLED_DISPLAY_WIDTH / OLED_FONT_WIDTH;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -313,6 +313,10 @@ bool oled_scroll_left(void);
 | 
			
		|||
// Returns true if the screen was not scrolling or stops scrolling
 | 
			
		||||
bool oled_scroll_off(void);
 | 
			
		||||
 | 
			
		||||
// Inverts the display
 | 
			
		||||
// Returns true if the screen was or is inverted
 | 
			
		||||
bool oled_invert(bool invert);
 | 
			
		||||
 | 
			
		||||
// Returns the maximum number of characters that will fit on a line
 | 
			
		||||
uint8_t oled_max_chars(void);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue