File tree Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change 3535SET_DISP_START_LINE  =  const (0x40 )
3636SET_SEG_REMAP  =  const (0xA0 )
3737SET_MUX_RATIO  =  const (0xA8 )
38+ SET_IREF_SELECT  =  const (0xAD )
3839SET_COM_OUT_DIR  =  const (0xC0 )
3940SET_DISP_OFFSET  =  const (0xD3 )
4041SET_COM_PIN_CFG  =  const (0xDA )
@@ -126,15 +127,14 @@ def init_display(self):
126127            0xFF ,  # maximum 
127128            SET_ENTIRE_ON ,  # output follows RAM contents 
128129            SET_NORM_INV ,  # not inverted 
130+             SET_IREF_SELECT ,
131+             0x30 ,  # enable internal IREF during display on 
129132            # charge pump 
130133            SET_CHARGE_PUMP ,
131134            0x10  if  self .external_vcc  else  0x14 ,
132135            SET_DISP  |  0x01 ,
133136        ):  # on 
134137            self .write_cmd (cmd )
135-         if  self .width  ==  72 :
136-             self .write_cmd (0xAD )
137-             self .write_cmd (0x30 )
138138        self .fill (0 )
139139        self .show ()
140140
@@ -177,14 +177,11 @@ def show(self):
177177        if  not  self .page_addressing :
178178            xpos0  =  0 
179179            xpos1  =  self .width  -  1 
180-             if  self .width  ==  64 :
181-                 # displays with width of 64 pixels are shifted by 32 
182-                 xpos0  +=  32 
183-                 xpos1  +=  32 
184-             if  self .width  ==  72 :
185-                 # displays with width of 72 pixels are shifted by 28 
186-                 xpos0  +=  28 
187-                 xpos1  +=  28 
180+             if  self .width  !=  128 :
181+                 # narrow displays use centered columns 
182+                 col_offset  =  (128  -  self .width ) //  2 
183+                 xpos0  +=  col_offset 
184+                 xpos1  +=  col_offset 
188185            self .write_cmd (SET_COL_ADDR )
189186            self .write_cmd (xpos0 )
190187            self .write_cmd (xpos1 )
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments