1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
diff --git a/firmware/export/config/sansaclipplus.h b/firmware/export/config/sansaclipplus.h
index c52d803..40a39e5 100644
--- a/firmware/export/config/sansaclipplus.h
+++ b/firmware/export/config/sansaclipplus.h
@@ -82,8 +82,8 @@
 #define HAVE_LCD_CONTRAST

 #define MIN_CONTRAST_SETTING        0
-#define MAX_CONTRAST_SETTING        50
-#define DEFAULT_CONTRAST_SETTING    30
+#define MAX_CONTRAST_SETTING        25
+#define DEFAULT_CONTRAST_SETTING    5

 #define IRAM_LCDFRAMEBUFFER IDATA_ATTR /* put the lcd frame buffer in IRAM */

diff --git a/firmware/target/arm/as3525/lcd-ssd1303.c b/firmware/target/arm/as3525/lcd-ssd1303.c
index e0e0715..0b5f90e 100644
--- a/firmware/target/arm/as3525/lcd-ssd1303.c
+++ b/firmware/target/arm/as3525/lcd-ssd1303.c
@@ -80,7 +80,7 @@ int lcd_default_contrast(void)
 void lcd_set_contrast(int val)
 {
     lcd_write_command(LCD_CNTL_CONTRAST);
-    lcd_write_command(val);
+    lcd_write_command(val * 10 + 1);
 }

 void lcd_set_invert_display(bool yesno)
@@ -139,47 +139,49 @@ void lcd_init_device(void)

     lcd_hw_init(&offset);

+    lcd_write_command(LCD_SET_DISPLAY_OFF);
+
     /* Set display clock (divide ratio = 1) and oscillator frequency (1) */
     lcd_write_command(LCD_SET_DISPLAY_CLOCK_AND_OSC_FREQ);
-    lcd_write_command(0x10);
-
-    /* Set VCOM deselect level to 0.76V */
-    lcd_write_command(LCD_SET_VCOM_DESELECT_LEVEL);
-    lcd_write_command(0x34);
-
-    /* Set pre-charge period (p1period is 2 dclk and p2period is 5 dclk) */
-    lcd_write_command(LCD_SET_PRECHARGE_PERIOD);
-    lcd_write_command(0x25);
+    lcd_write_command(0x80);

-    /* Set contrast register to 12% */
-    lcd_set_contrast(lcd_default_contrast());
-
-    /* Disable DC-DC */
-    lcd_write_command(LCD_SET_DC_DC);
-    lcd_write_command(LCD_SET_DC_DC_PART2/*|0*/);
+    lcd_write_command(LCD_SET_MULTIPLEX_RATIO);
+    lcd_write_command(0x3f);

     /* Set starting line as 0 */
     lcd_write_command(LCD_SET_DISPLAY_START_LINE /*|(0 & 0x3f)*/);

+    lcd_write_command(0x8d); //??
+
+    lcd_write_command (LCD_SET_HIGHER_COLUMN_ADDRESS /*| 0*/);
+
     /* Column 131 is remapped to SEG0 */
     lcd_write_command(LCD_SET_SEGMENT_REMAP_INV);

+    lcd_write_command(LCD_SET_DC_DC);
+    lcd_write_command(0x10);
+
     /* Invert COM scan direction (N-1 to 0) */
     lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION_INV);

-    /* Set normal display mode (not every pixel ON) */
-    lcd_write_command(LCD_SET_ENTIRE_DISPLAY_OFF);
+    lcd_write_command(0xda); // ??
+    lcd_write_command(0x12); // ??
+
+    /* Set pre-charge period (p1period is 2 dclk and p2period is 5 dclk) */
+    lcd_write_command(LCD_SET_PRECHARGE_PERIOD);
+    lcd_write_command(0x22);
+
+    /* Set VCOM deselect level to 0.76V */
+    lcd_write_command(LCD_SET_VCOM_DESELECT_LEVEL);
+    lcd_write_command(0x40);

-    /* Set normal display mode (not inverted) */
-    lcd_write_command(LCD_SET_NORMAL_DISPLAY);
+    /* Set contrast register to 12% */
+    lcd_set_contrast(lcd_default_contrast());

     /* Clear whole framebuffer, including "overscan"
      * We don't need to handle that out of screen columns in lcd_clear_display()
      * since we will never write into it anymore
      */
-    lcd_write_command (LCD_SET_HIGHER_COLUMN_ADDRESS /*| 0*/);
-    lcd_write_command (LCD_SET_LOWER_COLUMN_ADDRESS /*| 0*/);
-
     fb_data p_bytes[LCD_WIDTH + 2 * offset];
     memset(p_bytes, 0, sizeof(p_bytes)); /* fills with 0 : pixel off */
     for(i = 0; i < 8; i++)