Added ability to configure display rotation
This commit is contained in:
		
							
								
								
									
										90
									
								
								Display.h
									
									
									
									
									
								
							
							
						
						
									
										90
									
								
								Display.h
									
									
									
									
									
								
							@@ -201,6 +201,13 @@ bool display_init() {
 | 
			
		||||
      Wire.begin(SDA_OLED, SCL_OLED);
 | 
			
		||||
    #endif
 | 
			
		||||
 | 
			
		||||
    #if HAS_EEPROM
 | 
			
		||||
      uint8_t display_rotation = EEPROM.read(eeprom_addr(ADDR_CONF_DROT));
 | 
			
		||||
    #elif MCU_VARIANT == MCU_NRF52
 | 
			
		||||
      uint8_t display_rotation = eeprom_read(eeprom_addr(ADDR_CONF_DROT));
 | 
			
		||||
    #endif
 | 
			
		||||
    if (display_rotation < 0 or display_rotation > 3) display_rotation = 0xFF;
 | 
			
		||||
 | 
			
		||||
    #if DISP_CUSTOM_ADDR == true
 | 
			
		||||
      #if HAS_EEPROM
 | 
			
		||||
      uint8_t display_address = EEPROM.read(eeprom_addr(ADDR_CONF_DADR));
 | 
			
		||||
@@ -236,43 +243,52 @@ bool display_init() {
 | 
			
		||||
      return false;
 | 
			
		||||
    } else {
 | 
			
		||||
      set_contrast(&display, display_contrast);
 | 
			
		||||
      #if BOARD_MODEL == BOARD_RNODE_NG_20
 | 
			
		||||
        disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
        display.setRotation(3);
 | 
			
		||||
      #elif BOARD_MODEL == BOARD_RNODE_NG_21
 | 
			
		||||
        disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
        display.setRotation(3);
 | 
			
		||||
      #elif BOARD_MODEL == BOARD_LORA32_V1_0
 | 
			
		||||
        disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
        display.setRotation(3);
 | 
			
		||||
      #elif BOARD_MODEL == BOARD_LORA32_V2_0
 | 
			
		||||
        disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
        display.setRotation(3);
 | 
			
		||||
      #elif BOARD_MODEL == BOARD_LORA32_V2_1
 | 
			
		||||
        disp_mode = DISP_MODE_LANDSCAPE;
 | 
			
		||||
        display.setRotation(0);
 | 
			
		||||
      #elif BOARD_MODEL == BOARD_TBEAM
 | 
			
		||||
        disp_mode = DISP_MODE_LANDSCAPE;
 | 
			
		||||
        display.setRotation(0);
 | 
			
		||||
      #elif BOARD_MODEL == BOARD_TBEAM_S_V1
 | 
			
		||||
        disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
        display.setRotation(1);
 | 
			
		||||
      #elif BOARD_MODEL == BOARD_HELTEC32_V2
 | 
			
		||||
        disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
        display.setRotation(1);
 | 
			
		||||
      #elif BOARD_MODEL == BOARD_HELTEC32_V3
 | 
			
		||||
        disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
        display.setRotation(1);
 | 
			
		||||
      #elif BOARD_MODEL == BOARD_RAK4631
 | 
			
		||||
        disp_mode = DISP_MODE_LANDSCAPE;
 | 
			
		||||
        display.setRotation(0);
 | 
			
		||||
      #elif BOARD_MODEL == BOARD_TDECK
 | 
			
		||||
        disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
        display.setRotation(3);
 | 
			
		||||
      #else
 | 
			
		||||
        disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
        display.setRotation(3);
 | 
			
		||||
      #endif
 | 
			
		||||
      if (display_rotation != 0xFF) {
 | 
			
		||||
        if (display_rotation == 0 || display_rotation == 2) {
 | 
			
		||||
          disp_mode = DISP_MODE_LANDSCAPE;
 | 
			
		||||
        } else {
 | 
			
		||||
          disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
        }
 | 
			
		||||
        display.setRotation(display_rotation);
 | 
			
		||||
      } else {
 | 
			
		||||
        #if BOARD_MODEL == BOARD_RNODE_NG_20
 | 
			
		||||
          disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
          display.setRotation(3);
 | 
			
		||||
        #elif BOARD_MODEL == BOARD_RNODE_NG_21
 | 
			
		||||
          disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
          display.setRotation(3);
 | 
			
		||||
        #elif BOARD_MODEL == BOARD_LORA32_V1_0
 | 
			
		||||
          disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
          display.setRotation(3);
 | 
			
		||||
        #elif BOARD_MODEL == BOARD_LORA32_V2_0
 | 
			
		||||
          disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
          display.setRotation(3);
 | 
			
		||||
        #elif BOARD_MODEL == BOARD_LORA32_V2_1
 | 
			
		||||
          disp_mode = DISP_MODE_LANDSCAPE;
 | 
			
		||||
          display.setRotation(0);
 | 
			
		||||
        #elif BOARD_MODEL == BOARD_TBEAM
 | 
			
		||||
          disp_mode = DISP_MODE_LANDSCAPE;
 | 
			
		||||
          display.setRotation(0);
 | 
			
		||||
        #elif BOARD_MODEL == BOARD_TBEAM_S_V1
 | 
			
		||||
          disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
          display.setRotation(1);
 | 
			
		||||
        #elif BOARD_MODEL == BOARD_HELTEC32_V2
 | 
			
		||||
          disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
          display.setRotation(1);
 | 
			
		||||
        #elif BOARD_MODEL == BOARD_HELTEC32_V3
 | 
			
		||||
          disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
          display.setRotation(1);
 | 
			
		||||
        #elif BOARD_MODEL == BOARD_RAK4631
 | 
			
		||||
          disp_mode = DISP_MODE_LANDSCAPE;
 | 
			
		||||
          display.setRotation(0);
 | 
			
		||||
        #elif BOARD_MODEL == BOARD_TDECK
 | 
			
		||||
          disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
          display.setRotation(3);
 | 
			
		||||
        #else
 | 
			
		||||
          disp_mode = DISP_MODE_PORTRAIT;
 | 
			
		||||
          display.setRotation(3);
 | 
			
		||||
        #endif
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      update_area_positions();
 | 
			
		||||
      for (int i = 0; i < WATERFALL_SIZE; i++) {
 | 
			
		||||
 
 | 
			
		||||
@@ -56,6 +56,7 @@
 | 
			
		||||
  #define CMD_DISP_INT    0x45
 | 
			
		||||
  #define CMD_DISP_ADDR   0x63
 | 
			
		||||
  #define CMD_DISP_BLNK   0x64
 | 
			
		||||
  #define CMD_DISP_ROT    0x67
 | 
			
		||||
  #define CMD_NP_INT      0x65
 | 
			
		||||
  #define CMD_BT_CTRL     0x46
 | 
			
		||||
  #define CMD_BT_PIN      0x62
 | 
			
		||||
 
 | 
			
		||||
@@ -1099,6 +1099,21 @@ void serialCallback(uint8_t sbyte) {
 | 
			
		||||
            display_unblank();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
      #endif
 | 
			
		||||
    } else if (command == CMD_DISP_ROT) {
 | 
			
		||||
      #if HAS_DISPLAY
 | 
			
		||||
        if (sbyte == FESC) {
 | 
			
		||||
            ESCAPE = true;
 | 
			
		||||
        } else {
 | 
			
		||||
            if (ESCAPE) {
 | 
			
		||||
                if (sbyte == TFEND) sbyte = FEND;
 | 
			
		||||
                if (sbyte == TFESC) sbyte = FESC;
 | 
			
		||||
                ESCAPE = false;
 | 
			
		||||
            }
 | 
			
		||||
            drot_conf_save(sbyte);
 | 
			
		||||
            display_unblank();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
      #endif
 | 
			
		||||
    } else if (command == CMD_NP_INT) {
 | 
			
		||||
      #if HAS_NP
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								ROM.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								ROM.h
									
									
									
									
									
								
							@@ -39,6 +39,7 @@
 | 
			
		||||
  #define ADDR_CONF_DINT 0xB2
 | 
			
		||||
  #define ADDR_CONF_DADR 0xB3
 | 
			
		||||
  #define ADDR_CONF_DBLK 0xB4
 | 
			
		||||
  #define ADDR_CONF_DROT 0xB8
 | 
			
		||||
  #define ADDR_CONF_PSET 0xB5
 | 
			
		||||
  #define ADDR_CONF_PINT 0xB6
 | 
			
		||||
  #define ADDR_CONF_BSET 0xB7
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								Utilities.h
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								Utilities.h
									
									
									
									
									
								
							@@ -1507,6 +1507,16 @@ void db_conf_save(uint8_t val) {
 | 
			
		||||
	#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void drot_conf_save(uint8_t val) {
 | 
			
		||||
	#if HAS_DISPLAY
 | 
			
		||||
		if (val >= 0x00 and val <= 0x03) {
 | 
			
		||||
			eeprom_update(eeprom_addr(ADDR_CONF_BSET), CONF_OK_BYTE);
 | 
			
		||||
			eeprom_update(eeprom_addr(ADDR_CONF_DROT), val);
 | 
			
		||||
			hard_reset();
 | 
			
		||||
		}
 | 
			
		||||
	#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void np_int_conf_save(uint8_t p_int) {
 | 
			
		||||
	eeprom_update(eeprom_addr(ADDR_CONF_PSET), CONF_OK_BYTE);
 | 
			
		||||
	eeprom_update(eeprom_addr(ADDR_CONF_PINT), p_int);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user