new hardware
This commit is contained in:
82
MilliOhmMeter_FW/lib/U8g2/src/MUIU8g2.h
Normal file
82
MilliOhmMeter_FW/lib/U8g2/src/MUIU8g2.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
|
||||
MUIU8g2.h
|
||||
|
||||
C++ Arduino wrapper for clib/mui.h (monochome minimal user interface)
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MUIU8G2_HH
|
||||
#define MUIU8G2_HH
|
||||
|
||||
#include "clib/mui.h"
|
||||
#include "clib/mui_u8g2.h"
|
||||
|
||||
class MUIU8G2
|
||||
{
|
||||
protected:
|
||||
mui_t mui;
|
||||
public:
|
||||
MUIU8G2(void) { }
|
||||
|
||||
MUIU8G2(U8G2 &u8g2, fds_t *fds, muif_t *muif_list, size_t muif_cnt) {
|
||||
mui_Init(&mui, (void *)u8g2.getU8g2(), fds, muif_list, muif_cnt);
|
||||
}
|
||||
void begin(U8G2 &u8g2, fds_t *fds, muif_t *muif_list, size_t muif_cnt) {
|
||||
mui_Init(&mui, (void *)u8g2.getU8g2(), fds, muif_list, muif_cnt);
|
||||
}
|
||||
mui_t *getMUI(void) { return &mui; }
|
||||
|
||||
uint8_t getCurrentCursorFocusPosition(void) { return mui_GetCurrentCursorFocusPosition(&mui); }
|
||||
|
||||
int getCurrentFormId(void) { return mui_GetCurrentFormId(&mui); }
|
||||
|
||||
|
||||
void draw(void) { mui_Draw(&mui); }
|
||||
//void getSelectableFieldTextOption(fds_t *fds, uint8_t nth_token)
|
||||
// { mui_GetSelectableFieldTextOption(&mui, fds, nth_token); }
|
||||
void enterForm(fds_t *fds, uint8_t initial_cursor_position) { mui_EnterForm(&mui, fds, initial_cursor_position); }
|
||||
void leaveForm(void) { mui_LeaveForm(&mui); }
|
||||
uint8_t gotoForm(uint8_t form_id, uint8_t initial_cursor_position) { return mui_GotoForm(&mui, form_id, initial_cursor_position); }
|
||||
|
||||
void saveForm(void) { mui_SaveForm(&mui); }
|
||||
void restoreForm(void) { mui_RestoreForm(&mui); }
|
||||
void nextField(void) { mui_NextField(&mui); }
|
||||
void prevField(void) { mui_PrevField(&mui); }
|
||||
void sendSelect(void) { mui_SendSelect(&mui); }
|
||||
int isFormActive(void) { return mui_IsFormActive(&mui); }
|
||||
};
|
||||
|
||||
|
||||
#endif /* MUIU8G2_HH */
|
||||
@@ -39,9 +39,9 @@
|
||||
|
||||
#include "U8g2lib.h"
|
||||
|
||||
#ifdef ARDUINO
|
||||
static Print *u8g2_print_for_screenshot;
|
||||
|
||||
|
||||
void u8g2_print_callback(const char *s)
|
||||
{
|
||||
yield();
|
||||
@@ -71,6 +71,6 @@ void U8G2::writeBufferXBM2(Print &p)
|
||||
u8g2_print_for_screenshot = &p;
|
||||
u8g2_WriteBufferXBM2(getU8g2(), u8g2_print_callback);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,12 +38,22 @@
|
||||
|
||||
|
||||
#include "U8x8lib.h"
|
||||
|
||||
#ifdef ARDUINO
|
||||
|
||||
#ifdef U8X8_HAVE_HW_SPI
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
#ifdef U8X8_HAVE_HW_I2C
|
||||
#include <Wire.h>
|
||||
#endif
|
||||
# ifdef U8X8_HAVE_HW_I2C_TEENSY3
|
||||
# include <i2c_t3.h>
|
||||
# else
|
||||
# include <Wire.h>
|
||||
# endif
|
||||
#endif /* U8X8_HAVE_HW_I2C */
|
||||
|
||||
#endif /* ARDUINO */
|
||||
|
||||
|
||||
|
||||
@@ -72,6 +82,7 @@ size_t U8X8::write(uint8_t v)
|
||||
/*=============================================*/
|
||||
/*=== ARDUINO GPIO & DELAY ===*/
|
||||
|
||||
#ifdef ARDUINO
|
||||
#ifdef U8X8_USE_PINS
|
||||
extern "C" uint8_t u8x8_gpio_and_delay_arduino(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, U8X8_UNUSED void *arg_ptr)
|
||||
{
|
||||
@@ -1315,7 +1326,7 @@ extern "C" uint8_t u8x8_byte_arduino_hw_i2c(U8X8_UNUSED u8x8_t *u8x8, U8X8_UNUSE
|
||||
if ( u8x8->pins[U8X8_PIN_I2C_CLOCK] != U8X8_PIN_NONE && u8x8->pins[U8X8_PIN_I2C_DATA] != U8X8_PIN_NONE )
|
||||
{
|
||||
// second argument for the wire lib is the clock pin. In u8g2, the first argument of the clock pin in the clock/data pair
|
||||
Wire.begin(u8x8->pins[U8X8_PIN_I2C_DATA] , u8x8->pins[U8X8_PIN_I2C_CLOCK]);
|
||||
Wire.begin((int)u8x8->pins[U8X8_PIN_I2C_DATA] , u8x8->pins[U8X8_PIN_I2C_CLOCK]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1638,6 +1649,7 @@ extern "C" uint8_t u8x8_byte_arduino_ks0108(u8x8_t *u8x8, uint8_t msg, uint8_t a
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /*ARDUINO*/
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
954
MilliOhmMeter_FW/lib/U8g2/src/clib/mui.c
Normal file
954
MilliOhmMeter_FW/lib/U8g2/src/clib/mui.c
Normal file
@@ -0,0 +1,954 @@
|
||||
/*
|
||||
|
||||
mui.c
|
||||
|
||||
Monochrome minimal user interface: Core library.
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2021, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
|
||||
"mui.c" is a graphical user interface, developed as part of u8g2.
|
||||
However "mui.c" is independent of u8g2 and can be used without u8g2 code.
|
||||
The glue code between "mui.c" and u8g2 is located in "mui_u8g2.c"
|
||||
|
||||
c: cmd
|
||||
i: ID0
|
||||
j: ID1
|
||||
xy: Position (x and y)
|
||||
/text/: some text. The text can start with any delimiter (except 0 and |), but also has to end with the same delimiter
|
||||
a: Single char argument
|
||||
u: Single char argument with the user interface form number
|
||||
|
||||
"Uu" the interface --> no ID
|
||||
|
||||
Manual ID:
|
||||
"Fijxy" Generic field: Places field with id ii at x/y --> ID=ij
|
||||
"Bijxy/text/" Generic field (Button) with Text --> ID=ij
|
||||
"Tiixya/text/" Generic field with argument and text --> ID = ij
|
||||
"Aiixya"
|
||||
|
||||
Fixed ID:
|
||||
"Si" the style --> ID=@i
|
||||
"Lxy/labeltext/" Places a text at the specified position, field with - -> ID=.L, .l
|
||||
"Gxyu/menutext/" Go to the specified menu without placing the user interface form on the stack --> ID=.G, .g
|
||||
|
||||
|
||||
cijxy
|
||||
cijxy/text/
|
||||
cijxya/text/
|
||||
|
||||
cxy/text/
|
||||
cxya/text/
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "mui.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//#define mui_get_fds_char(s) ((uint8_t)(*s))
|
||||
|
||||
//#include <stdio.h>
|
||||
//#define MUI_DEBUG(...) printf(__VA_ARGS__)
|
||||
#define MUI_DEBUG(...)
|
||||
|
||||
uint8_t mui_get_fds_char(fds_t *s)
|
||||
{
|
||||
//return (uint8_t)(*s);
|
||||
return (uint8_t)mui_pgm_read(s);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
s must point to a valid command within FDS
|
||||
*/
|
||||
static size_t mui_fds_get_cmd_size_without_text(fds_t *s) MUI_NOINLINE;
|
||||
static size_t mui_fds_get_cmd_size_without_text(fds_t *s)
|
||||
{
|
||||
uint8_t c = mui_get_fds_char(s);
|
||||
c &= 0xdf; /* consider upper and lower case */
|
||||
switch(c)
|
||||
{
|
||||
case 'U': return 2; // User Form: CMD (1 Byte), Form-Id (1 Byte)
|
||||
case 'S': return 2; // Style: CMD (1 Byte), Style Id (1 Byte)
|
||||
case 'D': return 3; // Data within Text: CMD (1 Byte), ID (2 Bytes), Text (does not count here)
|
||||
case 'Z': return 3; // Zero field without x, y, arg & text: CMD (1 Byte), ID (2 Bytes)
|
||||
case 'F': return 5; // Field without arg & text: CMD (1 Byte), ID (2 Bytes), X, Y
|
||||
case 'B': return 5; // Field with text: CMD (1 Byte), ID (2 Bytes), X, Y, Text (does not count here)
|
||||
case 'T': return 6; // Field with arg & text: CMD (1 Byte), ID (2 Bytes), X, Y, Arg, Text (does not count here)
|
||||
case 'A': return 6; // Field with arg (no text): CMD (1 Byte), ID (2 Bytes), X, Y, Arg, Text
|
||||
case 'L': return 3; // Text Label: CMD (1 Byte), X, Y (same as 'B' but with fixed ID '.L', MUIF_LABEL, MUI_LABEL)
|
||||
case 'G': return 4; // Goto Btutton: CMD (1Byte), X, Y, Arg, Text (same as 'T' but with fixed ID '.G', MUIF_GOTO, MUI_GOTO)
|
||||
case 0: return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
s must point to the string delimiter start: first '/' for "B00ab/ok/"
|
||||
- '/' actually is 0xff
|
||||
- return the total size of the string, including the delimiter
|
||||
- copies the content of the string ("ok") to the ui text buffer
|
||||
|
||||
*/
|
||||
static size_t mui_fds_parse_text(mui_t *ui, fds_t *s)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
ui->delimiter = mui_get_fds_char(s);
|
||||
uint8_t c;
|
||||
fds_t *t = s;
|
||||
|
||||
//printf("mui_fds_parse_text del=%d\n", delimiter);
|
||||
#ifdef MUI_CHECK_EOFDS
|
||||
if ( ui->delimiter == 0 )
|
||||
return 0;
|
||||
#endif
|
||||
t++;
|
||||
for( ;; )
|
||||
{
|
||||
c = mui_get_fds_char(t);
|
||||
//printf("mui_fds_parse_text i=%d, c=%c\n", i, c);
|
||||
#ifdef MUI_CHECK_EOFDS
|
||||
if ( c == 0 )
|
||||
break;
|
||||
#endif
|
||||
if ( c == ui->delimiter )
|
||||
{
|
||||
t++;
|
||||
break;
|
||||
}
|
||||
if ( i < MUI_MAX_TEXT_LEN )
|
||||
{
|
||||
ui->text[i++] = c;
|
||||
}
|
||||
t++;
|
||||
}
|
||||
ui->text[i] = '\0' ;
|
||||
return t-s;
|
||||
}
|
||||
|
||||
/*
|
||||
get the first token within a text argument.
|
||||
The text argument may look like this:
|
||||
"B00ab/banana|apple|peach|cherry/"
|
||||
The outer delimiter "/" is not fixed and can be any char except "|" and "\0"
|
||||
The inner delimiter "|" is fixed. It must be the pipe symbol.
|
||||
This function will place "banana" into ui->text if the result is not 0
|
||||
|
||||
if ( mui_fds_first_token(ui) )
|
||||
{
|
||||
do
|
||||
{
|
||||
// handle token in ui->text
|
||||
} while ( mui_fds_next_token(ui) )
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
uint8_t mui_fds_first_token(mui_t *ui)
|
||||
{
|
||||
ui->token = ui->fds;
|
||||
ui->token += mui_fds_get_cmd_size_without_text(ui->fds);
|
||||
ui->delimiter = mui_get_fds_char(ui->token);
|
||||
ui->token++; // place ui->token on the first char of the token
|
||||
return mui_fds_next_token(ui);
|
||||
}
|
||||
|
||||
/*
|
||||
The inner token delimiter "|" is fixed. It must be the pipe symbol.
|
||||
*/
|
||||
uint8_t mui_fds_next_token(mui_t *ui)
|
||||
{
|
||||
uint8_t c;
|
||||
uint8_t i = 0;
|
||||
// printf("mui_fds_next_token: call, ui->token=%p\n", ui->token);
|
||||
for( ;; )
|
||||
{
|
||||
c = mui_get_fds_char(ui->token);
|
||||
// printf("mui_fds_next_token: i=%d c=%c\n", i, c);
|
||||
#ifdef MUI_CHECK_EOFDS
|
||||
if ( c == 0 )
|
||||
break;
|
||||
#endif
|
||||
if ( c == ui->delimiter )
|
||||
break;
|
||||
if ( c == '|' )
|
||||
{
|
||||
ui->token++; // place ui->token on the first char of the next token
|
||||
break;
|
||||
}
|
||||
|
||||
if ( i < MUI_MAX_TEXT_LEN )
|
||||
{
|
||||
ui->text[i++] = c;
|
||||
}
|
||||
|
||||
ui->token++;
|
||||
}
|
||||
ui->text[i] = '\0' ;
|
||||
if ( i == 0 )
|
||||
return 0; // no further token found
|
||||
return 1; // token placed in ui->text
|
||||
}
|
||||
|
||||
/*
|
||||
find nth token ('|' delimiter), return 0 if n exceeds the number of tokens, 1 otherwise
|
||||
the result is stored in ui->text
|
||||
*/
|
||||
uint8_t mui_fds_get_nth_token(mui_t *ui, uint8_t n)
|
||||
{
|
||||
// printf("mui_fds_get_nth_token: call, n=%d\n", n);
|
||||
if ( mui_fds_first_token(ui) )
|
||||
{
|
||||
do
|
||||
{
|
||||
if ( n == 0 )
|
||||
{
|
||||
// printf("mui_fds_get_nth_token: found");
|
||||
return 1;
|
||||
}
|
||||
n--;
|
||||
} while ( mui_fds_next_token(ui) );
|
||||
}
|
||||
//printf("mui_fds_get_nth_token: NOT found\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t mui_fds_get_token_cnt(mui_t *ui)
|
||||
{
|
||||
uint8_t n = 0;
|
||||
if ( mui_fds_first_token(ui) )
|
||||
{
|
||||
do
|
||||
{
|
||||
n++;
|
||||
} while ( mui_fds_next_token(ui) );
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
#define mui_fds_is_text(c) ( (c) == 'U' || (c) == 'S' || (c) == 'F' || (c) == 'A' || (c) == 'Z' ? 0 : 1 )
|
||||
|
||||
/*
|
||||
s must point to a valid command within FDS
|
||||
return
|
||||
The complete length of the command (including any text part)
|
||||
sideeffect:
|
||||
Any existing text part will be copied into ui->text
|
||||
ui->text will be assigned to empty string if there is no text argument
|
||||
*/
|
||||
static size_t mui_fds_get_cmd_size(mui_t *ui, fds_t *s) MUI_NOINLINE;
|
||||
static size_t mui_fds_get_cmd_size(mui_t *ui, fds_t *s)
|
||||
{
|
||||
size_t l = mui_fds_get_cmd_size_without_text(s);
|
||||
uint8_t c = mui_get_fds_char(s);
|
||||
ui->text[0] = '\0' ; /* always reset the text buffer */
|
||||
if ( mui_fds_is_text(c) )
|
||||
{
|
||||
l += mui_fds_parse_text(ui, s+l);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
mui_Init() will setup the menu system but will not activate or display anything.
|
||||
Use mui_GotoForm() after this command, then use mui_Draw() to draw the menu on a display.
|
||||
*/
|
||||
void mui_Init(mui_t *ui, void *graphics_data, fds_t *fds, muif_t *muif_tlist, size_t muif_tcnt)
|
||||
{
|
||||
memset(ui, 0, sizeof(mui_t));
|
||||
ui->root_fds = fds;
|
||||
//ui->current_form_fds = NULL; // not required, because there was a memset before
|
||||
ui->muif_tlist = muif_tlist;
|
||||
ui->muif_tcnt = muif_tcnt;
|
||||
ui->graphics_data = graphics_data;
|
||||
}
|
||||
|
||||
int mui_find_uif(mui_t *ui, uint8_t id0, uint8_t id1)
|
||||
{
|
||||
size_t i;
|
||||
for( i = 0; i < ui->muif_tcnt; i++ )
|
||||
{
|
||||
/*
|
||||
if ( ui->muif_tlist[i].id0 == id0 )
|
||||
if ( ui->muif_tlist[i].id1 == id1 )
|
||||
return i;
|
||||
*/
|
||||
if ( muif_get_id0(ui->muif_tlist+i) == id0 )
|
||||
if ( muif_get_id1(ui->muif_tlist+i) == id1 )
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
assumes a valid position in ui->fds and calculates all the other variables
|
||||
some fields are alway calculated like the ui->cmd and ui->len field
|
||||
other member vars are calculated only if the return value is 1
|
||||
will return 1 if the field id was found.
|
||||
will return 0 if the field id was not found in uif or if ui->fds points to something else than a field
|
||||
*/
|
||||
static uint8_t mui_prepare_current_field(mui_t *ui) MUI_NOINLINE;
|
||||
static uint8_t mui_prepare_current_field(mui_t *ui)
|
||||
{
|
||||
int muif_tidx;
|
||||
|
||||
ui->uif = NULL;
|
||||
ui->dflags = 0;
|
||||
ui->id0 = 0;
|
||||
ui->id1 = 0;
|
||||
ui->arg = 0;
|
||||
|
||||
/* calculate the length of the command and copy the text argument */
|
||||
/* this will also clear the text in cases where there is no text argument */
|
||||
ui->len = mui_fds_get_cmd_size(ui, ui->fds);
|
||||
//printf("mui_prepare_current_field len=%d\n", ui->len);
|
||||
|
||||
/* get the command and check whether end of form is reached */
|
||||
ui->cmd = mui_get_fds_char(ui->fds);
|
||||
//printf("mui_prepare_current_field cmd='%c' len=%d\n", ui->cmd, ui->len);
|
||||
|
||||
/* Copy the cmd also to second id value. This is required for some commands, others will overwrite this below */
|
||||
ui->id1 = ui->cmd;
|
||||
|
||||
/* now make the command uppercase so that both, upper and lower case are considered */
|
||||
ui->cmd &= 0xdf; /* consider upper and lower case */
|
||||
|
||||
if ( ui->cmd == 'U' || ui->cmd == 0 )
|
||||
return 0;
|
||||
|
||||
/* calculate the dynamic flags */
|
||||
if ( ui->fds == ui->cursor_focus_fds )
|
||||
ui->dflags |= MUIF_DFLAG_IS_CURSOR_FOCUS;
|
||||
if ( ui->fds == ui->touch_focus_fds )
|
||||
ui->dflags |= MUIF_DFLAG_IS_TOUCH_FOCUS;
|
||||
|
||||
|
||||
/* get the id0 and id1 values */
|
||||
if ( ui->cmd == 'F' || ui->cmd == 'B' || ui->cmd == 'T' || ui->cmd == 'A' )
|
||||
{
|
||||
ui->id0 = mui_get_fds_char(ui->fds+1);
|
||||
ui->id1 = mui_get_fds_char(ui->fds+2);
|
||||
ui->x = mui_get_fds_char(ui->fds+3);
|
||||
ui->y = mui_get_fds_char(ui->fds+4);
|
||||
if ( ui->cmd == 'A' || ui->cmd == 'T' )
|
||||
{
|
||||
ui->arg = mui_get_fds_char(ui->fds+5);
|
||||
}
|
||||
}
|
||||
else if ( ui->cmd == 'D' || ui->cmd == 'Z' )
|
||||
{
|
||||
ui->id0 = mui_get_fds_char(ui->fds+1);
|
||||
ui->id1 = mui_get_fds_char(ui->fds+2);
|
||||
}
|
||||
else if ( ui->cmd == 'S' )
|
||||
{
|
||||
ui->id0 = 'S';
|
||||
ui->id1 = mui_get_fds_char(ui->fds+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->id0 = '.';
|
||||
/* note that ui->id1 contains the original cmd value */
|
||||
ui->x = mui_get_fds_char(ui->fds+1);
|
||||
ui->y = mui_get_fds_char(ui->fds+2);
|
||||
if ( ui->cmd == 'G' || ui->cmd == 'M' ) /* this is also true for 'g' or 'm' */
|
||||
{
|
||||
ui->arg = mui_get_fds_char(ui->fds+3);
|
||||
}
|
||||
}
|
||||
|
||||
//MUI_DEBUG("mui_prepare_current_field cmd='%c' len=%d arg=%d\n", ui->cmd, ui->len, ui->arg);
|
||||
|
||||
|
||||
/* find the field */
|
||||
muif_tidx = mui_find_uif(ui, ui->id0, ui->id1);
|
||||
//printf("mui_prepare_current_field: muif_tidx=%d\n", muif_tidx);
|
||||
if ( muif_tidx >= 0 )
|
||||
{
|
||||
ui->uif = ui->muif_tlist + muif_tidx;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
assumes that ui->fds has been assigned correctly
|
||||
and that ui->target_fds and ui->tmp_fds had been cleared if required
|
||||
|
||||
Usually do not call this function directly, instead use mui_loop_over_form
|
||||
|
||||
*/
|
||||
|
||||
static void mui_inner_loop_over_form(mui_t *ui, uint8_t (*task)(mui_t *ui)) MUI_NOINLINE;
|
||||
static void mui_inner_loop_over_form(mui_t *ui, uint8_t (*task)(mui_t *ui))
|
||||
{
|
||||
uint8_t cmd;
|
||||
|
||||
//MUI_DEBUG("mui_inner_loop_over_form start %p\n", task);
|
||||
|
||||
ui->fds += mui_fds_get_cmd_size(ui, ui->fds); // skip the first entry, it is U always
|
||||
for(;;)
|
||||
{
|
||||
//printf("fds=%p *fds='%c'\n", ui->fds, ui->fds[0]);
|
||||
/* get the command and check whether end of form is reached */
|
||||
cmd = mui_get_fds_char(ui->fds);
|
||||
if ( cmd == 'U' || cmd == 0 )
|
||||
break;
|
||||
if ( mui_prepare_current_field(ui) )
|
||||
if ( task(ui) ) /* call the task, which was provided as argument to this function */
|
||||
{
|
||||
//MUI_DEBUG("mui_inner_loop_over_form break by task\n");
|
||||
break;
|
||||
}
|
||||
ui->fds += ui->len;
|
||||
}
|
||||
|
||||
//MUI_DEBUG("mui_inner_loop_over_form end %p\n", task);
|
||||
}
|
||||
|
||||
static void mui_loop_over_form(mui_t *ui, uint8_t (*task)(mui_t *ui)) MUI_NOINLINE;
|
||||
static void mui_loop_over_form(mui_t *ui, uint8_t (*task)(mui_t *ui))
|
||||
{
|
||||
if ( mui_IsFormActive(ui) == 0 )
|
||||
return;
|
||||
|
||||
ui->fds = ui->current_form_fds;
|
||||
ui->target_fds = NULL;
|
||||
ui->tmp_fds = NULL;
|
||||
|
||||
mui_inner_loop_over_form(ui, task);
|
||||
}
|
||||
|
||||
/*
|
||||
n is the form number
|
||||
*/
|
||||
fds_t *mui_find_form(mui_t *ui, uint8_t n)
|
||||
{
|
||||
fds_t *fds = ui->root_fds;
|
||||
uint8_t cmd;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
cmd = mui_get_fds_char(fds);
|
||||
if ( cmd == 0 )
|
||||
break;
|
||||
if ( cmd == 'U' )
|
||||
{
|
||||
if ( mui_get_fds_char(fds+1) == n )
|
||||
{
|
||||
return fds;
|
||||
}
|
||||
/* not found, just coninue */
|
||||
}
|
||||
|
||||
fds += mui_fds_get_cmd_size(ui, fds);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* === task procedures (arguments for mui_loop_over_form) === */
|
||||
/* ui->fds contains the current field */
|
||||
|
||||
uint8_t mui_task_draw(mui_t *ui)
|
||||
{
|
||||
//printf("mui_task_draw fds=%p uif=%p text=%s\n", ui->fds, ui->uif, ui->text);
|
||||
muif_get_cb(ui->uif)(ui, MUIF_MSG_DRAW);
|
||||
return 0; /* continue with the loop */
|
||||
}
|
||||
|
||||
uint8_t mui_task_form_start(mui_t *ui)
|
||||
{
|
||||
muif_get_cb(ui->uif)(ui, MUIF_MSG_FORM_START);
|
||||
return 0; /* continue with the loop */
|
||||
}
|
||||
|
||||
uint8_t mui_task_form_end(mui_t *ui)
|
||||
{
|
||||
muif_get_cb(ui->uif)(ui, MUIF_MSG_FORM_END);
|
||||
return 0; /* continue with the loop */
|
||||
}
|
||||
|
||||
static uint8_t mui_uif_is_cursor_selectable(mui_t *ui) MUI_NOINLINE;
|
||||
static uint8_t mui_uif_is_cursor_selectable(mui_t *ui)
|
||||
{
|
||||
if ( muif_get_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t mui_task_find_prev_cursor_uif(mui_t *ui)
|
||||
{
|
||||
//if ( muif_get_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
|
||||
if ( mui_uif_is_cursor_selectable(ui) )
|
||||
{
|
||||
if ( ui->fds == ui->cursor_focus_fds )
|
||||
{
|
||||
ui->target_fds = ui->tmp_fds;
|
||||
return 1; /* stop looping */
|
||||
}
|
||||
ui->tmp_fds = ui->fds;
|
||||
}
|
||||
return 0; /* continue with the loop */
|
||||
}
|
||||
|
||||
uint8_t mui_task_find_first_cursor_uif(mui_t *ui)
|
||||
{
|
||||
//if ( muif_get_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
|
||||
if ( mui_uif_is_cursor_selectable(ui) )
|
||||
{
|
||||
// if ( ui->target_fds == NULL )
|
||||
// {
|
||||
ui->target_fds = ui->fds;
|
||||
return 1; /* stop looping */
|
||||
// }
|
||||
}
|
||||
return 0; /* continue with the loop */
|
||||
}
|
||||
|
||||
uint8_t mui_task_find_last_cursor_uif(mui_t *ui)
|
||||
{
|
||||
//if ( muif_get_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
|
||||
if ( mui_uif_is_cursor_selectable(ui) )
|
||||
{
|
||||
//ui->cursor_focus_position++;
|
||||
ui->target_fds = ui->fds;
|
||||
}
|
||||
return 0; /* continue with the loop */
|
||||
}
|
||||
|
||||
uint8_t mui_task_find_next_cursor_uif(mui_t *ui)
|
||||
{
|
||||
//if ( muif_get_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
|
||||
if ( mui_uif_is_cursor_selectable(ui) )
|
||||
{
|
||||
if ( ui->tmp_fds != NULL )
|
||||
{
|
||||
ui->target_fds = ui->fds;
|
||||
ui->tmp_fds = NULL;
|
||||
return 1; /* stop looping */
|
||||
}
|
||||
if ( ui->fds == ui->cursor_focus_fds )
|
||||
{
|
||||
ui->tmp_fds = ui->fds;
|
||||
}
|
||||
}
|
||||
return 0; /* continue with the loop */
|
||||
}
|
||||
|
||||
uint8_t mui_task_get_current_cursor_focus_position(mui_t *ui)
|
||||
{
|
||||
//if ( muif_get_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
|
||||
if ( mui_uif_is_cursor_selectable(ui) )
|
||||
{
|
||||
if ( ui->fds == ui->cursor_focus_fds )
|
||||
return 1; /* stop looping */
|
||||
ui->tmp8++;
|
||||
}
|
||||
return 0; /* continue with the loop */
|
||||
}
|
||||
|
||||
uint8_t mui_task_read_nth_selectable_field(mui_t *ui)
|
||||
{
|
||||
//if ( muif_get_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
|
||||
if ( mui_uif_is_cursor_selectable(ui) )
|
||||
{
|
||||
if ( ui->tmp8 == 0 )
|
||||
return 1; /* stop looping */
|
||||
ui->tmp8--;
|
||||
}
|
||||
return 0; /* continue with the loop */
|
||||
}
|
||||
|
||||
|
||||
/* === utility functions for the user API === */
|
||||
|
||||
static uint8_t mui_send_cursor_msg(mui_t *ui, uint8_t msg) MUI_NOINLINE;
|
||||
static uint8_t mui_send_cursor_msg(mui_t *ui, uint8_t msg)
|
||||
{
|
||||
if ( ui->cursor_focus_fds )
|
||||
{
|
||||
ui->fds = ui->cursor_focus_fds;
|
||||
if ( mui_prepare_current_field(ui) )
|
||||
return muif_get_cb(ui->uif)(ui, msg);
|
||||
}
|
||||
return 0; /* not called, msg not handled */
|
||||
}
|
||||
|
||||
/* === user API === */
|
||||
|
||||
/*
|
||||
returns the field pos which has the current focus
|
||||
If the first selectable field has the focus, then 0 will be returned
|
||||
Unselectable fields (for example labels) are skipped by this count.
|
||||
If no fields are selectable, then 0 is returned
|
||||
|
||||
The return value can be used as last argument for mui_EnterForm or mui_GotoForm
|
||||
|
||||
WARNING: This function will destroy current fds and field information.
|
||||
*/
|
||||
uint8_t mui_GetCurrentCursorFocusPosition(mui_t *ui)
|
||||
{
|
||||
//fds_t *fds = ui->fds;
|
||||
ui->tmp8 = 0;
|
||||
mui_loop_over_form(ui, mui_task_get_current_cursor_focus_position);
|
||||
//ui->fds = fds;
|
||||
return ui->tmp8;
|
||||
}
|
||||
|
||||
|
||||
void mui_Draw(mui_t *ui)
|
||||
{
|
||||
mui_loop_over_form(ui, mui_task_draw);
|
||||
}
|
||||
|
||||
void mui_next_field(mui_t *ui)
|
||||
{
|
||||
mui_loop_over_form(ui, mui_task_find_next_cursor_uif);
|
||||
// ui->cursor_focus_position++;
|
||||
ui->cursor_focus_fds = ui->target_fds; // NULL is ok
|
||||
if ( ui->target_fds == NULL )
|
||||
{
|
||||
mui_loop_over_form(ui, mui_task_find_first_cursor_uif);
|
||||
ui->cursor_focus_fds = ui->target_fds; // NULL is ok
|
||||
// ui->cursor_focus_position = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
this function will overwrite the ui field related member variables
|
||||
nth_token can be 0 if the fiel text is not a option list
|
||||
the result is stored in ui->text
|
||||
*/
|
||||
/* OBSOLETE */
|
||||
#ifdef OBSOLETE
|
||||
void mui_GetSelectableFieldTextOptionByCursorPosition(mui_t *ui, uint8_t form_id, uint8_t cursor_position, uint8_t nth_token)
|
||||
|
||||
fds_t *fds = ui->fds; // backup the current fds, so that this function can be called inside a task loop
|
||||
int len = ui->len; // backup length of the current command
|
||||
|
||||
|
||||
ui->fds = mui_find_form(ui, form_id); // search for the target form and overwrite the current fds
|
||||
|
||||
// use the inner_loop procedure, because ui->fds has been assigned already
|
||||
ui->tmp8 = cursor_position; // maybe we should also backup tmp8, but at the moment tmp8 is only used by mui_task_get_current_cursor_focus_position
|
||||
//MUI_DEBUG("mui_GetSelectableFieldTextOption\n");
|
||||
mui_inner_loop_over_form(ui, mui_task_read_nth_selectable_field);
|
||||
// at this point ui->fds contains the field which was selected from above
|
||||
|
||||
// now get the opion string out of the text field. nth_token can be 0 if this is no opion string
|
||||
mui_fds_get_nth_token(ui, nth_token); // return value is ignored here
|
||||
|
||||
ui->fds = fds; // restore the previous fds position
|
||||
ui->len = len;
|
||||
// result is stored in ui->text
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
this function will overwrite the ui field related member variables
|
||||
nth_token can be 0 if the fiel text is not a option list
|
||||
the result is stored in ui->text
|
||||
|
||||
token delimiter is '|' (pipe symbol)
|
||||
|
||||
fds: The start of a field (MUI_DATA)
|
||||
nth_token: The position of the token, which should be returned
|
||||
*/
|
||||
uint8_t mui_GetSelectableFieldTextOption(mui_t *ui, fds_t *fds, uint8_t nth_token)
|
||||
{
|
||||
fds_t *fds_backup = ui->fds; // backup the current fds, so that this function can be called inside a task loop
|
||||
int len = ui->len; // backup length of the current command, 26 sep 2021: probably this is not required any more
|
||||
uint8_t is_found;
|
||||
|
||||
ui->fds = fds;
|
||||
// at this point ui->fds contains the field which contains the tokens
|
||||
// now get the opion string out of the text field. nth_token can be 0 if this is no opion string
|
||||
is_found = mui_fds_get_nth_token(ui, nth_token); // return value is ignored here
|
||||
|
||||
ui->fds = fds_backup; // restore the previous fds position
|
||||
ui->len = len;
|
||||
// result is stored in ui->text
|
||||
return is_found;
|
||||
}
|
||||
|
||||
/*
|
||||
this function will overwrite the ui field related member variables
|
||||
return the number of options in the referenced field
|
||||
*/
|
||||
/* OBSOLETE */
|
||||
#ifdef OBSOLETE
|
||||
uint8_t mui_GetSelectableFieldOptionCntByCursorPosition(mui_t *ui, uint8_t form_id, uint8_t cursor_position)
|
||||
{
|
||||
fds_t *fds = ui->fds; // backup the current fds, so that this function can be called inside a task loop
|
||||
int len = ui->len; // backup length of the current command
|
||||
uint8_t cnt = 0;
|
||||
|
||||
ui->fds = mui_find_form(ui, form_id); // search for the target form and overwrite the current fds
|
||||
|
||||
// use the inner_loop procedure, because ui->fds has been assigned already
|
||||
ui->tmp8 = cursor_position; // maybe we should also backup tmp8, but at the moment tmp8 is only used by mui_task_get_current_cursor_focus_position
|
||||
//MUI_DEBUG("mui_GetSelectableFieldOptionCnt\n");
|
||||
mui_inner_loop_over_form(ui, mui_task_read_nth_selectable_field);
|
||||
// at this point ui->fds contains the field which was selected from above
|
||||
|
||||
// now get the opion string out of the text field. nth_token can be 0 if this is no opion string
|
||||
cnt = mui_fds_get_token_cnt(ui);
|
||||
|
||||
ui->fds = fds; // restore the previous fds position
|
||||
ui->len = len;
|
||||
// result is stored in ui->text
|
||||
return cnt;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t mui_GetSelectableFieldOptionCnt(mui_t *ui, fds_t *fds)
|
||||
{
|
||||
fds_t *fds_backup = ui->fds; // backup the current fds, so that this function can be called inside a task loop
|
||||
int len = ui->len; // backup length of the current command 26 sep 2021: probably this is not required any more
|
||||
uint8_t cnt = 0;
|
||||
|
||||
ui->fds = fds;
|
||||
// at this point ui->fds contains the field which contains the tokens
|
||||
// now get the opion string out of the text field. nth_token can be 0 if this is no opion string
|
||||
cnt = mui_fds_get_token_cnt(ui);
|
||||
|
||||
ui->fds = fds_backup; // restore the previous fds position
|
||||
ui->len = len;
|
||||
// result is stored in ui->text
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//static void mui_send_cursor_enter_msg(mui_t *ui) MUI_NOINLINE;
|
||||
static uint8_t mui_send_cursor_enter_msg(mui_t *ui)
|
||||
{
|
||||
ui->is_mud = 0;
|
||||
return mui_send_cursor_msg(ui, MUIF_MSG_CURSOR_ENTER);
|
||||
}
|
||||
|
||||
/*
|
||||
if called from a field function, then the current field variables are destroyed, so that call should be the last call in the field callback.
|
||||
mui_EnterForm is similar to mui_GotoForm and differes only in the second argument (which is the form id instead of the fds pointer)
|
||||
*/
|
||||
void mui_EnterForm(mui_t *ui, fds_t *fds, uint8_t initial_cursor_position)
|
||||
{
|
||||
/* exit any previous form, will not do anything if there is no current form */
|
||||
mui_LeaveForm(ui);
|
||||
|
||||
/* clean focus fields */
|
||||
ui->touch_focus_fds = NULL;
|
||||
ui->cursor_focus_fds = NULL;
|
||||
|
||||
/* reset all the scoll values */
|
||||
ui->form_scroll_top = 0;
|
||||
ui->form_scroll_visible = 0;
|
||||
ui->form_scroll_total = 0;
|
||||
|
||||
/* assign the form, which should be entered */
|
||||
ui->current_form_fds = fds;
|
||||
|
||||
/* inform all fields that we start a new form */
|
||||
MUI_DEBUG("mui_EnterForm: form_start, initial_cursor_position=%d\n", initial_cursor_position);
|
||||
mui_loop_over_form(ui, mui_task_form_start);
|
||||
|
||||
/* assign initional cursor focus */
|
||||
MUI_DEBUG("mui_EnterForm: find_first_cursor_uif\n");
|
||||
mui_loop_over_form(ui, mui_task_find_first_cursor_uif);
|
||||
ui->cursor_focus_fds = ui->target_fds; // NULL is ok
|
||||
MUI_DEBUG("mui_EnterForm: find_first_cursor_uif target_fds=%p\n", ui->target_fds);
|
||||
|
||||
while( initial_cursor_position > 0 )
|
||||
{
|
||||
mui_NextField(ui); // mui_next_field(ui) is not sufficient in case of scrolling
|
||||
initial_cursor_position--;
|
||||
}
|
||||
|
||||
while( mui_send_cursor_enter_msg(ui) == 255 )
|
||||
{
|
||||
mui_NextField(ui); // mui_next_field(ui) is not sufficient in case of scrolling
|
||||
}
|
||||
}
|
||||
|
||||
/* input: current_form_fds */
|
||||
/*
|
||||
if called from a field function, then the current field variables are destroyed, so that call should be the last call in the field callback.
|
||||
*/
|
||||
void mui_LeaveForm(mui_t *ui)
|
||||
{
|
||||
if ( mui_IsFormActive(ui) == 0 )
|
||||
return;
|
||||
|
||||
mui_send_cursor_msg(ui, MUIF_MSG_CURSOR_LEAVE);
|
||||
ui->cursor_focus_fds = NULL;
|
||||
|
||||
/* inform all fields that we leave the form */
|
||||
MUI_DEBUG("mui_LeaveForm: form_end\n");
|
||||
mui_loop_over_form(ui, mui_task_form_end);
|
||||
ui->current_form_fds = NULL;
|
||||
}
|
||||
|
||||
/* 0: error, form not found */
|
||||
/*
|
||||
if called from a field function, then the current field variables are destroyed, so that call should be the last call in the field callback.
|
||||
*/
|
||||
uint8_t mui_GotoForm(mui_t *ui, uint8_t form_id, uint8_t initial_cursor_position)
|
||||
{
|
||||
fds_t *fds = mui_find_form(ui, form_id);
|
||||
if ( fds == NULL )
|
||||
return 0;
|
||||
/* EnterForm will also leave any previous form */
|
||||
mui_EnterForm(ui, fds, initial_cursor_position);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void mui_SaveForm(mui_t *ui)
|
||||
{
|
||||
if ( mui_IsFormActive(ui) == 0 )
|
||||
return;
|
||||
|
||||
ui->last_form_fds = ui->cursor_focus_fds;
|
||||
ui->last_form_id = mui_get_fds_char(ui->current_form_fds+1);
|
||||
ui->last_form_cursor_focus_position = mui_GetCurrentCursorFocusPosition(ui);
|
||||
}
|
||||
|
||||
/*
|
||||
if called from a field function, then the current field variables are destroyed, so that call should be the last call in the field callback.
|
||||
*/
|
||||
void mui_RestoreForm(mui_t *ui)
|
||||
{
|
||||
mui_GotoForm(ui, ui->last_form_id, ui->last_form_cursor_focus_position);
|
||||
}
|
||||
|
||||
/*
|
||||
Save a cursor position for mui_GotoFormAutoCursorPosition command
|
||||
Only one such position is stored.
|
||||
*/
|
||||
void mui_SaveCursorPosition(mui_t *ui, uint8_t cursor_position)
|
||||
{
|
||||
uint8_t form_id = mui_get_fds_char(ui->current_form_fds+1);
|
||||
MUI_DEBUG("mui_SaveCursorPosition form_id=%d cursor_position=%d\n", form_id, cursor_position);
|
||||
|
||||
if ( form_id == ui->menu_form_id[0] )
|
||||
ui->menu_form_last_added = 0;
|
||||
else if ( form_id == ui->menu_form_id[1] )
|
||||
ui->menu_form_last_added = 1;
|
||||
else
|
||||
ui->menu_form_last_added ^= 1;
|
||||
ui->menu_form_id[ui->menu_form_last_added] = form_id;
|
||||
ui->menu_form_cursor_focus_position[ui->menu_form_last_added] = cursor_position;
|
||||
MUI_DEBUG("mui_SaveCursorPosition ui->menu_form_last_added=%d \n", ui->menu_form_last_added);
|
||||
}
|
||||
|
||||
/*
|
||||
Similar to mui_GotoForm, but will jump to previously stored cursor location (mui_SaveCursorPosition) or 0 if the cursor position was not saved.
|
||||
*/
|
||||
uint8_t mui_GotoFormAutoCursorPosition(mui_t *ui, uint8_t form_id)
|
||||
{
|
||||
uint8_t cursor_position = 0;
|
||||
if ( form_id == ui->menu_form_id[0] )
|
||||
cursor_position = ui->menu_form_cursor_focus_position[0];
|
||||
if ( form_id == ui->menu_form_id[1] )
|
||||
cursor_position = ui->menu_form_cursor_focus_position[1];
|
||||
MUI_DEBUG("mui_GotoFormAutoCursorPosition form_id=%d cursor_position=%d\n", form_id, cursor_position);
|
||||
return mui_GotoForm(ui, form_id, cursor_position);
|
||||
}
|
||||
|
||||
/*
|
||||
return current form id or -1 if the menu system is inactive
|
||||
*/
|
||||
int mui_GetCurrentFormId(mui_t *ui)
|
||||
{
|
||||
if ( mui_IsFormActive(ui) == 0 )
|
||||
return -1;
|
||||
return mui_get_fds_char(ui->current_form_fds+1);
|
||||
}
|
||||
|
||||
/*
|
||||
updates "ui->cursor_focus_fds"
|
||||
*/
|
||||
/*
|
||||
if called from a field function, then the current field variables are destroyed, so that call should be the last call in the field callback.
|
||||
*/
|
||||
void mui_NextField(mui_t *ui)
|
||||
{
|
||||
do
|
||||
{
|
||||
if ( mui_send_cursor_msg(ui, MUIF_MSG_EVENT_NEXT) )
|
||||
return;
|
||||
mui_send_cursor_msg(ui, MUIF_MSG_CURSOR_LEAVE);
|
||||
mui_next_field(ui);
|
||||
} while ( mui_send_cursor_enter_msg(ui) == 255 );
|
||||
}
|
||||
|
||||
/*
|
||||
updates "ui->cursor_focus_fds"
|
||||
*/
|
||||
/*
|
||||
if called from a field function, then the current field variables are destroyed, so that call should be the last call in the field callback.
|
||||
*/
|
||||
void mui_PrevField(mui_t *ui)
|
||||
{
|
||||
do
|
||||
{
|
||||
if ( mui_send_cursor_msg(ui, MUIF_MSG_EVENT_PREV) )
|
||||
return;
|
||||
mui_send_cursor_msg(ui, MUIF_MSG_CURSOR_LEAVE);
|
||||
|
||||
mui_loop_over_form(ui, mui_task_find_prev_cursor_uif);
|
||||
ui->cursor_focus_fds = ui->target_fds; // NULL is ok
|
||||
if ( ui->target_fds == NULL )
|
||||
{
|
||||
//ui->cursor_focus_position = 0;
|
||||
mui_loop_over_form(ui, mui_task_find_last_cursor_uif);
|
||||
ui->cursor_focus_fds = ui->target_fds; // NULL is ok
|
||||
}
|
||||
} while( mui_send_cursor_enter_msg(ui) == 255 );
|
||||
}
|
||||
|
||||
|
||||
void mui_SendSelect(mui_t *ui)
|
||||
{
|
||||
mui_send_cursor_msg(ui, MUIF_MSG_CURSOR_SELECT);
|
||||
}
|
||||
|
||||
592
MilliOhmMeter_FW/lib/U8g2/src/clib/mui.h
Normal file
592
MilliOhmMeter_FW/lib/U8g2/src/clib/mui.h
Normal file
@@ -0,0 +1,592 @@
|
||||
/*
|
||||
|
||||
mui.h
|
||||
|
||||
Monochrome minimal user interface: Core library.
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2021, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
MUIF (Monochrome User Interface Functions)
|
||||
n: A number 0 to 9 without any quotes, e.g.: 5
|
||||
id: Exactly two characters or numbers in doubl quotes, e.g. "G5".
|
||||
cb: A callback function with the following prototype: "uint8_t muif_cb(mui_t *ui, uint8_t msg)"
|
||||
There are MANY predefined callback functions, see separate list
|
||||
var: Address of a variable.
|
||||
text: Normal text, but special characters might be required for some callback functions, for
|
||||
example the text might contain a list of selectable elements separated with the '|' symbol.
|
||||
|
||||
MUIF_STYLE(n,cb)
|
||||
Corresponding FDS command: MUI_STYLE(n)
|
||||
Change the style of any other elements after MUI_STYLE(n), does not draw anything
|
||||
|
||||
MUIF_RO(id,cb)
|
||||
Corresponding FDS command: MUI_DATA(id, text) MUI_XY(id, x, y), MUI_XYT(id, x,y,text), MUI_XYA(id, x,y,a), MUI_XYAT(id, x,y,a,text)
|
||||
Places a read only element on the form.
|
||||
The correct FDS command depends on the callback function.
|
||||
|
||||
MUIF_LABEL(cb)
|
||||
Corresponding FDS command: MUI_LABEL(x,y,text)
|
||||
Places a text at the specified position, similar to MUIF_RO
|
||||
|
||||
MUIF_GOTO(cb)
|
||||
Corresponding FDS command: MUI_GOTO(x,y,n,text)
|
||||
Places a button at the specified position, similar to MUIF_BUTTON, but does not require an ID.
|
||||
|
||||
MUIF_BUTTON(id,cb)
|
||||
Corresponding FDS command: MUI_XY(id, x, y), MUI_XYT(id, x,y,text), MUI_XYA(id, x,y,a), MUI_XYAT(id, x,y,a,text)
|
||||
Places a selectable element on the form.
|
||||
|
||||
MUIF_VARIABLE(id,var,cb)
|
||||
Corresponding FDS command: MUI_XY(id, x, y), MUI_XYA(id, x,y,a)
|
||||
Places a user input element at the specified location.
|
||||
The correct FDS command depends on the callback function.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#ifndef MUI_H
|
||||
#define MUI_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(__GNUC__) && defined(__AVR__)
|
||||
#include <avr/pgmspace.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*==========================================*/
|
||||
/* C++ compatible */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*==========================================*/
|
||||
/* defines */
|
||||
|
||||
#define MUI_CHECK_EOFDS
|
||||
|
||||
|
||||
/*==========================================*/
|
||||
/* GNUC AVR PROGMEM interface */
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define MUI_NOINLINE __attribute__((noinline))
|
||||
#else
|
||||
# define MUI_NOINLINE
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__GNUC__) && defined(__AVR__)
|
||||
# define mui_pgm_read(adr) pgm_read_byte_near(adr)
|
||||
# define mui_pgm_wread(adr) pgm_read_word_near(adr)
|
||||
# define MUI_PROGMEM PROGMEM
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef mui_pgm_read
|
||||
# ifndef CHAR_BIT
|
||||
# define mui_pgm_read(adr) (*(const uint8_t *)(adr))
|
||||
# else
|
||||
# if CHAR_BIT > 8
|
||||
# define mui_pgm_read(adr) ((*(const uint8_t *)(adr)) & 0x0ff)
|
||||
# else
|
||||
# define mui_pgm_read(adr) (*(const uint8_t *)(adr))
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef mui_pgm_wread
|
||||
# define mui_pgm_wread(adr) (*(const uint16_t *)(adr))
|
||||
#endif
|
||||
|
||||
#ifndef MUI_PROGMEM
|
||||
# define MUI_PROGMEM
|
||||
#endif
|
||||
|
||||
|
||||
/*=== forward declarations ===*/
|
||||
typedef struct mui_struct mui_t;
|
||||
typedef const struct muif_struct muif_t;
|
||||
typedef uint8_t (*muif_cb)(mui_t *ui, uint8_t msg);
|
||||
typedef const char fds_t MUI_PROGMEM;
|
||||
|
||||
|
||||
|
||||
/*=== struct declarations === */
|
||||
|
||||
struct muif_struct
|
||||
{
|
||||
uint8_t id0;
|
||||
uint8_t id1;
|
||||
uint8_t cflags; // config flags e.g. MUIF_CFLAG_IS_CURSOR_SELECTABLE, if so, then it will not receive any cursor/touch msgs
|
||||
uint8_t extra;
|
||||
void *data; // might be a pointer to a variable
|
||||
muif_cb cb; // callback
|
||||
} MUI_PROGMEM;
|
||||
|
||||
#define MUIF(id,cflags,data,cb) { id[0], id[1], cflags, 0, data, cb}
|
||||
#define MUIF_STYLE(n,cb) MUIF("S" #n, 0, 0, cb)
|
||||
#define MUIF_RO(id,cb) MUIF(id,0, 0,cb)
|
||||
#define MUIF_LABEL(cb) MUIF(".L",0, 0,cb)
|
||||
#define MUIF_GOTO(cb) MUIF(".G",MUIF_CFLAG_IS_CURSOR_SELECTABLE,0,cb)
|
||||
#define MUIF_BUTTON(id,cb) MUIF(id,MUIF_CFLAG_IS_CURSOR_SELECTABLE,0,cb)
|
||||
#define MUIF_VARIABLE(id,var,cb) MUIF(id,MUIF_CFLAG_IS_CURSOR_SELECTABLE,(var),cb)
|
||||
|
||||
/* assumes that pointers are 16 bit so encapusalte the wread i another ifdef __AVR__ */
|
||||
#if defined(__GNUC__) && defined(__AVR__)
|
||||
# define muif_get_id0(muif) mui_pgm_read(&((muif)->id0))
|
||||
# define muif_get_id1(muif) mui_pgm_read(&((muif)->id1))
|
||||
# define muif_get_cflags(muif) mui_pgm_read(&((muif)->cflags))
|
||||
# define muif_get_extra(muif) mui_pgm_read(&((muif)->extra))
|
||||
# define muif_get_data(muif) ((void *)mui_pgm_wread(&((muif)->data)))
|
||||
# define muif_get_cb(muif) ((muif_cb)mui_pgm_wread(&((muif)->cb)))
|
||||
#else
|
||||
# define muif_get_id0(muif) ((muif)->id0)
|
||||
# define muif_get_id1(muif) ((muif)->id1)
|
||||
# define muif_get_cflags(muif) ((muif)->cflags)
|
||||
# define muif_get_extra(muif) ((muif)->extra)
|
||||
# define muif_get_data(muif) ((muif)->data)
|
||||
# define muif_get_cb(muif) ((muif)->cb)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define MUIF_MSG_NONE 0
|
||||
#define MUIF_MSG_DRAW 1
|
||||
#define MUIF_MSG_FORM_START 2
|
||||
#define MUIF_MSG_FORM_END 3
|
||||
/* MUIF_MSG_CURSOR_ENTER return values: 255=skip this field, <255, continue*/
|
||||
#define MUIF_MSG_CURSOR_ENTER 4
|
||||
#define MUIF_MSG_CURSOR_SELECT 5
|
||||
#define MUIF_MSG_CURSOR_LEAVE 6
|
||||
#define MUIF_MSG_TOUCH_DOWN 7
|
||||
#define MUIF_MSG_TOUCH_UP 8
|
||||
/* MUIF_MSG_EVENT_NEXT return values: 0=not handled, 1=handled, do nothing */
|
||||
#define MUIF_MSG_EVENT_NEXT 9
|
||||
/* MUIF_MSG_EVENT_PREV return values: 0=not handled, 1=handled, do nothing */
|
||||
#define MUIF_MSG_EVENT_PREV 10
|
||||
|
||||
/* dynamic flags */
|
||||
#define MUIF_DFLAG_IS_CURSOR_FOCUS 0x01
|
||||
#define MUIF_DFLAG_IS_TOUCH_FOCUS 0x02
|
||||
|
||||
/* config flags */
|
||||
#define MUIF_CFLAG_IS_CURSOR_SELECTABLE 0x01
|
||||
#define MUIF_CFLAG_IS_TOUCH_SELECTABLE 0x02
|
||||
|
||||
|
||||
/* must be smaller than or equal to 255 */
|
||||
#define MUI_MAX_TEXT_LEN 41
|
||||
|
||||
#define MUI_MENU_CACHE_CNT 2
|
||||
|
||||
struct mui_struct
|
||||
{
|
||||
void *graphics_data;
|
||||
fds_t *root_fds;
|
||||
|
||||
muif_t *muif_tlist;
|
||||
size_t muif_tcnt;
|
||||
|
||||
fds_t *current_form_fds; // the current form, NULL if the ui is not active at the moment
|
||||
fds_t *cursor_focus_fds; // the field which has the current cursor focus, NULL if there is no current focus
|
||||
fds_t *touch_focus_fds; // the field which has touch focus
|
||||
|
||||
fds_t *token; // current token position
|
||||
|
||||
uint16_t form_scroll_total; // reserved for MUIF, not used by mui
|
||||
uint16_t form_scroll_top; // reserved for MUIF, not used by mui
|
||||
uint8_t form_scroll_visible; // reserved for MUIF, not used by mui
|
||||
|
||||
|
||||
//uint8_t selected_value; // This variable is not used by the user interface but can be used by any field function
|
||||
uint8_t tmp8;
|
||||
|
||||
/* 0: mse, 1: mud */
|
||||
uint8_t is_mud; // a temp variable for the MUIF function to store remember up down mode. This variable will be cleared before sending MUIF_MSG_CURSOR_ENTER
|
||||
/* current field/style variables */
|
||||
//uint8_t cursor_focus_position; // the index of the field which has focus, can be used as last argument for mui_EnterForm
|
||||
|
||||
uint8_t delimiter; // outer delimiter of the text part of a field
|
||||
uint8_t cmd; // current cmd or field (e.g. U or F)
|
||||
uint8_t id0; // identifier of the field, manually provided or derived (G cmd has fixed id "FG")
|
||||
uint8_t id1;
|
||||
uint8_t x; // position of the field
|
||||
uint8_t y;
|
||||
uint8_t dflags;
|
||||
uint8_t arg; // extra argument of the field. For example the G: form is put here
|
||||
int len; // length of the current command
|
||||
fds_t *fds; // current position, *fds = cmd
|
||||
muif_t *uif; // user interface field or style for the given id0 / id1
|
||||
char text[MUI_MAX_TEXT_LEN+1];
|
||||
|
||||
/* target */
|
||||
fds_t *tmp_fds;
|
||||
fds_t *target_fds; // used by several task functions as a return / result value
|
||||
|
||||
/* last form and field, used by mui_SaveForm and mui_RestoreForm */
|
||||
uint8_t last_form_id;
|
||||
uint8_t last_form_cursor_focus_position;
|
||||
fds_t *last_form_fds; // not used by mui_RestoreForm, but can be used by field functions
|
||||
|
||||
/* menu cursor position backup */
|
||||
uint8_t menu_form_id[MUI_MENU_CACHE_CNT];
|
||||
uint8_t menu_form_cursor_focus_position[MUI_MENU_CACHE_CNT];
|
||||
uint8_t menu_form_last_added;
|
||||
} ;
|
||||
|
||||
#define mui_IsCursorFocus(mui) ((mui)->dflags & MUIF_DFLAG_IS_CURSOR_FOCUS)
|
||||
#define mui_IsTouchFocus(mui) ((mui)->dflags & MUIF_CFLAG_IS_TOUCH_SELECTABLE)
|
||||
|
||||
|
||||
|
||||
|
||||
/*=== form string definitions ===*/
|
||||
|
||||
#define MUI_0 "\x00"
|
||||
#define MUI_1 "\x01"
|
||||
#define MUI_2 "\x02"
|
||||
#define MUI_3 "\x03"
|
||||
#define MUI_4 "\x04"
|
||||
#define MUI_5 "\x05"
|
||||
#define MUI_6 "\x06"
|
||||
#define MUI_7 "\x07"
|
||||
#define MUI_8 "\x08"
|
||||
#define MUI_9 "\x09"
|
||||
#define MUI_10 "\x0a"
|
||||
#define MUI_11 "\x0b"
|
||||
#define MUI_12 "\x0c"
|
||||
#define MUI_13 "\x0d"
|
||||
#define MUI_14 "\x0e"
|
||||
#define MUI_15 "\x0f"
|
||||
#define MUI_16 "\x10"
|
||||
#define MUI_17 "\x11"
|
||||
#define MUI_18 "\x12"
|
||||
#define MUI_19 "\x13"
|
||||
#define MUI_20 "\x14"
|
||||
#define MUI_21 "\x15"
|
||||
#define MUI_22 "\x16"
|
||||
#define MUI_23 "\x17"
|
||||
#define MUI_24 "\x18"
|
||||
#define MUI_25 "\x19"
|
||||
#define MUI_26 "\x1a"
|
||||
#define MUI_27 "\x1b"
|
||||
#define MUI_28 "\x1c"
|
||||
#define MUI_29 "\x1d"
|
||||
#define MUI_30 "\x1e"
|
||||
#define MUI_31 "\x1f"
|
||||
#define MUI_32 "\x20"
|
||||
#define MUI_33 "\x21"
|
||||
#define MUI_34 "\x22"
|
||||
#define MUI_35 "\x23"
|
||||
#define MUI_36 "\x24"
|
||||
#define MUI_37 "\x25"
|
||||
#define MUI_38 "\x26"
|
||||
#define MUI_39 "\x27"
|
||||
#define MUI_40 "\x28"
|
||||
#define MUI_41 "\x29"
|
||||
#define MUI_42 "\x2a"
|
||||
#define MUI_43 "\x2b"
|
||||
#define MUI_44 "\x2c"
|
||||
#define MUI_45 "\x2d"
|
||||
#define MUI_46 "\x2e"
|
||||
#define MUI_47 "\x2f"
|
||||
#define MUI_48 "\x30"
|
||||
#define MUI_49 "\x31"
|
||||
#define MUI_50 "\x32"
|
||||
#define MUI_51 "\x33"
|
||||
#define MUI_52 "\x34"
|
||||
#define MUI_53 "\x35"
|
||||
#define MUI_54 "\x36"
|
||||
#define MUI_55 "\x37"
|
||||
#define MUI_56 "\x38"
|
||||
#define MUI_57 "\x39"
|
||||
#define MUI_58 "\x3a"
|
||||
#define MUI_59 "\x3b"
|
||||
#define MUI_60 "\x3c"
|
||||
#define MUI_61 "\x3d"
|
||||
#define MUI_62 "\x3e"
|
||||
#define MUI_63 "\x3f"
|
||||
#define MUI_64 "\x40"
|
||||
#define MUI_65 "\x41"
|
||||
#define MUI_66 "\x42"
|
||||
#define MUI_67 "\x43"
|
||||
#define MUI_68 "\x44"
|
||||
#define MUI_69 "\x45"
|
||||
#define MUI_70 "\x46"
|
||||
#define MUI_71 "\x47"
|
||||
#define MUI_72 "\x48"
|
||||
#define MUI_73 "\x49"
|
||||
#define MUI_74 "\x4a"
|
||||
#define MUI_75 "\x4b"
|
||||
#define MUI_76 "\x4c"
|
||||
#define MUI_77 "\x4d"
|
||||
#define MUI_78 "\x4e"
|
||||
#define MUI_79 "\x4f"
|
||||
#define MUI_80 "\x50"
|
||||
#define MUI_81 "\x51"
|
||||
#define MUI_82 "\x52"
|
||||
#define MUI_83 "\x53"
|
||||
#define MUI_84 "\x54"
|
||||
#define MUI_85 "\x55"
|
||||
#define MUI_86 "\x56"
|
||||
#define MUI_87 "\x57"
|
||||
#define MUI_88 "\x58"
|
||||
#define MUI_89 "\x59"
|
||||
#define MUI_90 "\x5a"
|
||||
#define MUI_91 "\x5b"
|
||||
#define MUI_92 "\x5c"
|
||||
#define MUI_93 "\x5d"
|
||||
#define MUI_94 "\x5e"
|
||||
#define MUI_95 "\x5f"
|
||||
#define MUI_96 "\x60"
|
||||
#define MUI_97 "\x61"
|
||||
#define MUI_98 "\x62"
|
||||
#define MUI_99 "\x63"
|
||||
#define MUI_100 "\x64"
|
||||
#define MUI_101 "\x65"
|
||||
#define MUI_102 "\x66"
|
||||
#define MUI_103 "\x67"
|
||||
#define MUI_104 "\x68"
|
||||
#define MUI_105 "\x69"
|
||||
#define MUI_106 "\x6a"
|
||||
#define MUI_107 "\x6b"
|
||||
#define MUI_108 "\x6c"
|
||||
#define MUI_109 "\x6d"
|
||||
#define MUI_110 "\x6e"
|
||||
#define MUI_111 "\x6f"
|
||||
#define MUI_112 "\x70"
|
||||
#define MUI_113 "\x71"
|
||||
#define MUI_114 "\x72"
|
||||
#define MUI_115 "\x73"
|
||||
#define MUI_116 "\x74"
|
||||
#define MUI_117 "\x75"
|
||||
#define MUI_118 "\x76"
|
||||
#define MUI_119 "\x77"
|
||||
#define MUI_120 "\x78"
|
||||
#define MUI_121 "\x79"
|
||||
#define MUI_122 "\x7a"
|
||||
#define MUI_123 "\x7b"
|
||||
#define MUI_124 "\x7c"
|
||||
#define MUI_125 "\x7d"
|
||||
#define MUI_126 "\x7e"
|
||||
#define MUI_127 "\x7f"
|
||||
#define MUI_128 "\x80"
|
||||
#define MUI_129 "\x81"
|
||||
#define MUI_130 "\x82"
|
||||
#define MUI_131 "\x83"
|
||||
#define MUI_132 "\x84"
|
||||
#define MUI_133 "\x85"
|
||||
#define MUI_134 "\x86"
|
||||
#define MUI_135 "\x87"
|
||||
#define MUI_136 "\x88"
|
||||
#define MUI_137 "\x89"
|
||||
#define MUI_138 "\x8a"
|
||||
#define MUI_139 "\x8b"
|
||||
#define MUI_140 "\x8c"
|
||||
#define MUI_141 "\x8d"
|
||||
#define MUI_142 "\x8e"
|
||||
#define MUI_143 "\x8f"
|
||||
#define MUI_144 "\x90"
|
||||
#define MUI_145 "\x91"
|
||||
#define MUI_146 "\x92"
|
||||
#define MUI_147 "\x93"
|
||||
#define MUI_148 "\x94"
|
||||
#define MUI_149 "\x95"
|
||||
#define MUI_150 "\x96"
|
||||
#define MUI_151 "\x97"
|
||||
#define MUI_152 "\x98"
|
||||
#define MUI_153 "\x99"
|
||||
#define MUI_154 "\x9a"
|
||||
#define MUI_155 "\x9b"
|
||||
#define MUI_156 "\x9c"
|
||||
#define MUI_157 "\x9d"
|
||||
#define MUI_158 "\x9e"
|
||||
#define MUI_159 "\x9f"
|
||||
#define MUI_160 "\xa0"
|
||||
#define MUI_161 "\xa1"
|
||||
#define MUI_162 "\xa2"
|
||||
#define MUI_163 "\xa3"
|
||||
#define MUI_164 "\xa4"
|
||||
#define MUI_165 "\xa5"
|
||||
#define MUI_166 "\xa6"
|
||||
#define MUI_167 "\xa7"
|
||||
#define MUI_168 "\xa8"
|
||||
#define MUI_169 "\xa9"
|
||||
#define MUI_170 "\xaa"
|
||||
#define MUI_171 "\xab"
|
||||
#define MUI_172 "\xac"
|
||||
#define MUI_173 "\xad"
|
||||
#define MUI_174 "\xae"
|
||||
#define MUI_175 "\xaf"
|
||||
#define MUI_176 "\xb0"
|
||||
#define MUI_177 "\xb1"
|
||||
#define MUI_178 "\xb2"
|
||||
#define MUI_179 "\xb3"
|
||||
#define MUI_180 "\xb4"
|
||||
#define MUI_181 "\xb5"
|
||||
#define MUI_182 "\xb6"
|
||||
#define MUI_183 "\xb7"
|
||||
#define MUI_184 "\xb8"
|
||||
#define MUI_185 "\xb9"
|
||||
#define MUI_186 "\xba"
|
||||
#define MUI_187 "\xbb"
|
||||
#define MUI_188 "\xbc"
|
||||
#define MUI_189 "\xbd"
|
||||
#define MUI_190 "\xbe"
|
||||
#define MUI_191 "\xbf"
|
||||
#define MUI_192 "\xc0"
|
||||
#define MUI_193 "\xc1"
|
||||
#define MUI_194 "\xc2"
|
||||
#define MUI_195 "\xc3"
|
||||
#define MUI_196 "\xc4"
|
||||
#define MUI_197 "\xc5"
|
||||
#define MUI_198 "\xc6"
|
||||
#define MUI_199 "\xc7"
|
||||
#define MUI_200 "\xc8"
|
||||
#define MUI_201 "\xc9"
|
||||
#define MUI_202 "\xca"
|
||||
#define MUI_203 "\xcb"
|
||||
#define MUI_204 "\xcc"
|
||||
#define MUI_205 "\xcd"
|
||||
#define MUI_206 "\xce"
|
||||
#define MUI_207 "\xcf"
|
||||
#define MUI_208 "\xd0"
|
||||
#define MUI_209 "\xd1"
|
||||
#define MUI_210 "\xd2"
|
||||
#define MUI_211 "\xd3"
|
||||
#define MUI_212 "\xd4"
|
||||
#define MUI_213 "\xd5"
|
||||
#define MUI_214 "\xd6"
|
||||
#define MUI_215 "\xd7"
|
||||
#define MUI_216 "\xd8"
|
||||
#define MUI_217 "\xd9"
|
||||
#define MUI_218 "\xda"
|
||||
#define MUI_219 "\xdb"
|
||||
#define MUI_220 "\xdc"
|
||||
#define MUI_221 "\xdd"
|
||||
#define MUI_222 "\xde"
|
||||
#define MUI_223 "\xdf"
|
||||
#define MUI_224 "\xe0"
|
||||
#define MUI_225 "\xe1"
|
||||
#define MUI_226 "\xe2"
|
||||
#define MUI_227 "\xe3"
|
||||
#define MUI_228 "\xe4"
|
||||
#define MUI_229 "\xe5"
|
||||
#define MUI_230 "\xe6"
|
||||
#define MUI_231 "\xe7"
|
||||
#define MUI_232 "\xe8"
|
||||
#define MUI_233 "\xe9"
|
||||
#define MUI_234 "\xea"
|
||||
#define MUI_235 "\xeb"
|
||||
#define MUI_236 "\xec"
|
||||
#define MUI_237 "\xed"
|
||||
#define MUI_238 "\xee"
|
||||
#define MUI_239 "\xef"
|
||||
#define MUI_240 "\xf0"
|
||||
#define MUI_241 "\xf1"
|
||||
#define MUI_242 "\xf2"
|
||||
#define MUI_243 "\xf3"
|
||||
#define MUI_244 "\xf4"
|
||||
#define MUI_245 "\xf5"
|
||||
#define MUI_246 "\xf6"
|
||||
#define MUI_247 "\xf7"
|
||||
#define MUI_248 "\xf8"
|
||||
#define MUI_249 "\xf9"
|
||||
#define MUI_250 "\xfa"
|
||||
#define MUI_251 "\xfb"
|
||||
#define MUI_252 "\xfc"
|
||||
#define MUI_253 "\xfd"
|
||||
#define MUI_254 "\xfe"
|
||||
#define MUI_255 "\xff"
|
||||
|
||||
/* form: one id only */
|
||||
#define MUI_FORM(n) "U" MUI_##n
|
||||
|
||||
/* style: one id only */
|
||||
#define MUI_STYLE(n) "S" #n
|
||||
|
||||
#define MUI_AUX(id) "Z" id
|
||||
|
||||
#define MUI_DATA(id, text) "D" id "\xff" text "\xff"
|
||||
|
||||
#define MUI_XY(id, x, y) "F" id MUI_##x MUI_##y
|
||||
/* button id must be two chars, but must be unique everywhere */
|
||||
#define MUI_XYT(id, x,y,text) "B" id MUI_##x MUI_##y "\xff" text "\xff"
|
||||
#define MUI_XYA(id, x,y,a) "A" id MUI_##x MUI_##y MUI_##a
|
||||
#define MUI_XYAT(id, x,y,a,text) "T" id MUI_##x MUI_##y MUI_##a "\xff" text "\xff"
|
||||
|
||||
#define MUI_LABEL(x,y,text) "L" MUI_##x MUI_##y "\xff" text "\xff"
|
||||
#define MUI_GOTO(x,y,n,text) "G" MUI_##x MUI_##y MUI_##n "\xff" text "\xff"
|
||||
#define MUI_goto(x,y,n,text) "g" MUI_##x MUI_##y MUI_##n "\xff" text "\xff"
|
||||
|
||||
|
||||
uint8_t mui_get_fds_char(fds_t *s) MUI_NOINLINE;
|
||||
|
||||
uint8_t mui_fds_first_token(mui_t *ui) MUI_NOINLINE;
|
||||
uint8_t mui_fds_next_token(mui_t *ui) MUI_NOINLINE;
|
||||
uint8_t mui_fds_get_nth_token(mui_t *ui, uint8_t n) MUI_NOINLINE;
|
||||
uint8_t mui_fds_get_token_cnt(mui_t *ui) MUI_NOINLINE;
|
||||
|
||||
void mui_Init(mui_t *ui, void *graphics_data, fds_t *fds, muif_t *muif_tlist, size_t muif_tcnt);
|
||||
uint8_t mui_GetCurrentCursorFocusPosition(mui_t *ui) ;
|
||||
void mui_Draw(mui_t *ui);
|
||||
/* warning: The next function will overwrite the ui field variables like ui->arg, etc. 26 sep 2021: only ui->text is modified */
|
||||
uint8_t mui_GetSelectableFieldTextOption(mui_t *ui, fds_t *fds, uint8_t nth_token);
|
||||
/* warning: The next function will overwrite the ui field variables like ui->arg, etc 26 sep 2021: only ui->text is modified*/
|
||||
uint8_t mui_GetSelectableFieldOptionCnt(mui_t *ui, fds_t *fds);
|
||||
void mui_EnterForm(mui_t *ui, fds_t *fds, uint8_t initial_cursor_position);
|
||||
void mui_LeaveForm(mui_t *ui);
|
||||
uint8_t mui_GotoForm(mui_t *ui, uint8_t form_id, uint8_t initial_cursor_position);
|
||||
void mui_SaveForm(mui_t *ui); /* Save current form+cursor position. Used together with mui_RestoreForm */
|
||||
void mui_RestoreForm(mui_t *ui); /* Restore form and cursor position, previously saved with mui_SaveForm */
|
||||
void mui_SaveCursorPosition(mui_t *ui, uint8_t cursor_position); /* stores a cursor position for use with mui_GotoFormAutoCursorPosition */
|
||||
uint8_t mui_GotoFormAutoCursorPosition(mui_t *ui, uint8_t form_id);
|
||||
|
||||
int mui_GetCurrentFormId(mui_t *ui); /* form id or -1 if the menu system is inactive */
|
||||
void mui_NextField(mui_t *ui);
|
||||
void mui_PrevField(mui_t *ui);
|
||||
void mui_SendSelect(mui_t *ui);
|
||||
|
||||
|
||||
|
||||
#define mui_IsFormActive(ui) ((ui)->current_form_fds != NULL)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MUI_H */
|
||||
|
||||
2038
MilliOhmMeter_FW/lib/U8g2/src/clib/mui_u8g2.c
Normal file
2038
MilliOhmMeter_FW/lib/U8g2/src/clib/mui_u8g2.c
Normal file
File diff suppressed because it is too large
Load Diff
251
MilliOhmMeter_FW/lib/U8g2/src/clib/mui_u8g2.h
Normal file
251
MilliOhmMeter_FW/lib/U8g2/src/clib/mui_u8g2.h
Normal file
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
|
||||
mui_u8g2.h
|
||||
|
||||
Monochrome minimal user interface: Glue code between mui and u8g2.
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2021, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef MUI_U8G2_H
|
||||
#define MUI_U8G2_H
|
||||
|
||||
#include "mui.h"
|
||||
|
||||
/*==========================================*/
|
||||
/* C++ compatible */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define MUI_U8G2_COMMA ,
|
||||
|
||||
typedef const char * (*mui_u8g2_get_list_element_cb)(void *data, uint16_t index);
|
||||
typedef uint16_t (*mui_u8g2_get_list_count_cb)(void *data);
|
||||
|
||||
struct mui_u8g2_list_struct
|
||||
{
|
||||
uint16_t *selection;
|
||||
void *data;
|
||||
mui_u8g2_get_list_element_cb get_list_element;
|
||||
mui_u8g2_get_list_count_cb get_list_count;
|
||||
} MUI_PROGMEM;
|
||||
|
||||
typedef const struct mui_u8g2_list_struct mui_u8g2_list_t;
|
||||
|
||||
#if defined(__GNUC__) && defined(__AVR__)
|
||||
# define mui_u8g2_list_get_selection_ptr(list) ((uint16_t *)mui_pgm_wread(&((list)->selection)))
|
||||
# define mui_u8g2_list_get_data_ptr(list) ((void *)mui_pgm_wread(&((list)->data)))
|
||||
# define mui_u8g2_list_get_element_cb(list) ((mui_u8g2_get_list_element_cb)mui_pgm_wread(&((list)->get_list_element)))
|
||||
# define mui_u8g2_list_get_count_cb(list) ((mui_u8g2_get_list_count_cb)mui_pgm_wread(&((list)->get_list_count)))
|
||||
#else
|
||||
# define mui_u8g2_list_get_selection_ptr(list) ((list)->selection)
|
||||
# define mui_u8g2_list_get_data_ptr(list) ((list)->data)
|
||||
# define mui_u8g2_list_get_element_cb(list) ((list)->get_list_element)
|
||||
# define mui_u8g2_list_get_count_cb(list) ((list)->get_list_count)
|
||||
#endif
|
||||
|
||||
|
||||
struct mui_u8g2_u8_min_max_struct
|
||||
{
|
||||
uint8_t *value;
|
||||
uint8_t min;
|
||||
uint8_t max;
|
||||
} MUI_PROGMEM;
|
||||
|
||||
typedef const struct mui_u8g2_u8_min_max_struct mui_u8g2_u8_min_max_t;
|
||||
|
||||
#if defined(__GNUC__) && defined(__AVR__)
|
||||
# define mui_u8g2_u8mm_get_min(u8mm) mui_pgm_read(&((u8mm)->min))
|
||||
# define mui_u8g2_u8mm_get_max(u8mm) mui_pgm_read(&((u8mm)->max))
|
||||
# define mui_u8g2_u8mm_get_valptr(u8mm) ((uint8_t *)mui_pgm_wread(&((u8mm)->value)))
|
||||
#else
|
||||
# define mui_u8g2_u8mm_get_min(u8mm) ((u8mm)->min)
|
||||
# define mui_u8g2_u8mm_get_max(u8mm) ((u8mm)->max)
|
||||
# define mui_u8g2_u8mm_get_valptr(u8mm) ((u8mm)->value)
|
||||
#endif
|
||||
|
||||
|
||||
struct mui_u8g2_u8_min_max_step_struct
|
||||
{
|
||||
uint8_t *value;
|
||||
uint8_t min;
|
||||
uint8_t max;
|
||||
uint8_t step;
|
||||
uint8_t flags;
|
||||
} MUI_PROGMEM;
|
||||
|
||||
typedef const struct mui_u8g2_u8_min_max_step_struct mui_u8g2_u8_min_max_step_t;
|
||||
|
||||
#if defined(__GNUC__) && defined(__AVR__)
|
||||
# define mui_u8g2_u8mms_get_step(u8mm) mui_pgm_read(&((u8mm)->step))
|
||||
# define mui_u8g2_u8mms_get_flags(u8mm) mui_pgm_read(&((u8mm)->flags))
|
||||
# define mui_u8g2_u8mms_get_min(u8mm) mui_pgm_read(&((u8mm)->min))
|
||||
# define mui_u8g2_u8mms_get_max(u8mm) mui_pgm_read(&((u8mm)->max))
|
||||
# define mui_u8g2_u8mms_get_valptr(u8mm) ((uint8_t *)mui_pgm_wread(&((u8mm)->value)))
|
||||
#else
|
||||
# define mui_u8g2_u8mms_get_step(u8mm) ((u8mm)->step)
|
||||
# define mui_u8g2_u8mms_get_flags(u8mm) ((u8mm)->flags)
|
||||
# define mui_u8g2_u8mms_get_min(u8mm) ((u8mm)->min)
|
||||
# define mui_u8g2_u8mms_get_max(u8mm) ((u8mm)->max)
|
||||
# define mui_u8g2_u8mms_get_valptr(u8mm) ((u8mm)->value)
|
||||
#endif
|
||||
|
||||
|
||||
/* helper functions */
|
||||
|
||||
u8g2_uint_t mui_get_x(mui_t *ui);
|
||||
u8g2_uint_t mui_get_y(mui_t *ui);
|
||||
u8g2_t *mui_get_U8g2(mui_t *ui);
|
||||
|
||||
u8g2_uint_t mui_u8g2_get_draw_button_pi_flags(mui_t *ui) MUI_NOINLINE;
|
||||
void mui_u8g2_draw_button_utf(mui_t *ui, u8g2_uint_t flags, u8g2_uint_t width, u8g2_uint_t padding_h, u8g2_uint_t padding_v, const char *text) MUI_NOINLINE;
|
||||
void mui_u8g2_draw_button_utf_pi(mui_t *ui, u8g2_uint_t width, u8g2_uint_t padding_h, const char *text);
|
||||
|
||||
|
||||
|
||||
/* ready to use field functions */
|
||||
|
||||
uint8_t mui_u8g2_draw_text(mui_t *ui, uint8_t msg);
|
||||
uint8_t mui_u8g2_btn_goto_wm_fi(mui_t *ui, uint8_t msg); /* GIF */
|
||||
uint8_t mui_u8g2_btn_goto_wm_if(mui_t *ui, uint8_t msg);
|
||||
uint8_t mui_u8g2_btn_goto_w2_fi(mui_t *ui, uint8_t msg); /* GIF */
|
||||
uint8_t mui_u8g2_btn_goto_w2_if(mui_t *ui, uint8_t msg);
|
||||
|
||||
uint8_t mui_u8g2_btn_goto_w1_pi(mui_t *ui, uint8_t msg); /* GIF */
|
||||
uint8_t mui_u8g2_btn_goto_w1_fi(mui_t *ui, uint8_t msg); /* GIF */
|
||||
|
||||
uint8_t mui_u8g2_btn_exit_wm_fi(mui_t *ui, uint8_t msg); /* similar to 'mui_u8g2_btn_goto_wm_fi' but will exit the menu system */
|
||||
|
||||
uint8_t mui_u8g2_u8_chkbox_wm_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE, MUI_XY */
|
||||
uint8_t mui_u8g2_u8_radio_wm_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE,MUI_XYAT */
|
||||
|
||||
|
||||
|
||||
uint8_t mui_u8g2_u8_opt_line_wa_mse_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE,MUI_XYAT */
|
||||
uint8_t mui_u8g2_u8_opt_line_wa_mse_pf(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE,MUI_XYAT */
|
||||
uint8_t mui_u8g2_u8_opt_line_wa_mud_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE,MUI_XYAT */
|
||||
uint8_t mui_u8g2_u8_opt_line_wa_mud_pf(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE,MUI_XYAT */
|
||||
|
||||
/* The text part of the parent defines a '|' separted list of elements, which can be selected by the child. */
|
||||
/* Argument is a form number where the child element is placed multiple times */
|
||||
/* The child form does not require the ok button, because the child function will return to the parent with the select element */
|
||||
uint8_t mui_u8g2_u8_opt_parent_wm_mse_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE, MUI_XYAT */
|
||||
uint8_t mui_u8g2_u8_opt_radio_child_wm_mse_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE, MUI_XYA */
|
||||
uint8_t mui_u8g2_u8_opt_radio_child_w1_mse_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE, MUI_XYA */
|
||||
uint8_t mui_u8g2_u8_opt_child_wm_mse_pi(mui_t *ui, uint8_t msg); /* MUIF_VARIABLE, MUI_XYA */
|
||||
|
||||
|
||||
//uint8_t mui_u8g2_goto_parent(mui_t *ui, uint8_t msg); /* MUIF_RO, MUI_DATA (WARNING: Must appear only once per form!!! */
|
||||
// renamed to
|
||||
uint8_t mui_u8g2_goto_data(mui_t *ui, uint8_t msg); /* REF, MUIF_RO, MUI_DATA (WARNING: Must appear only once per form!!! */
|
||||
//uint8_t mui_u8g2_goto_child_w1_mse_pi(mui_t *ui, uint8_t msg); /* MUIF_BUTTON, MUI_XYA */
|
||||
// renamed to
|
||||
uint8_t mui_u8g2_goto_form_w1_mse_pi(mui_t *ui, uint8_t msg); /* REF, MUIF_BUTTON, MUI_XYA */
|
||||
uint8_t mui_u8g2_goto_form_w1_mse_pf(mui_t *ui, uint8_t msg); /* REF, MUIF_BUTTON, MUI_XYA */
|
||||
|
||||
|
||||
uint8_t mui_u8g2_u8_char_wm_mud_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE,MUI_XY, usually requires a monospaced font line profont12 */
|
||||
|
||||
|
||||
/*===== MUIF U8g2 Label =====*/
|
||||
|
||||
#define MUIF_U8G2_LABEL() MUIF_LABEL(mui_u8g2_draw_text)
|
||||
|
||||
|
||||
/*===== data = u8g2 font data =====*/
|
||||
|
||||
//#define MUIF_U8G2_FONT_STYLE(n,font) MUIF("S" #n, 0, (void *)(font), mui_u8g2_set_font_style_function)
|
||||
#define MUIF_U8G2_FONT_STYLE(n, font) { 'S', #n[0], 0, 0, (void *)(font), mui_u8g2_set_font_style_function}
|
||||
|
||||
|
||||
uint8_t mui_u8g2_set_font_style_function(mui_t *ui, uint8_t msg);
|
||||
|
||||
|
||||
/*===== data = mui_u8g2_u8_min_max_t* =====*/
|
||||
|
||||
/* gcc note: the macro uses array compound literals to extend the lifetime in C++, see last section in https://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html */
|
||||
#define MUIF_U8G2_U8_MIN_MAX(id, valptr, min, max, muif) \
|
||||
MUIF(id, MUIF_CFLAG_IS_CURSOR_SELECTABLE, \
|
||||
(void *)((mui_u8g2_u8_min_max_t [] ) {{ (valptr) MUI_U8G2_COMMA (min) MUI_U8G2_COMMA (max)}}), \
|
||||
(muif))
|
||||
|
||||
uint8_t mui_u8g2_u8_min_max_wm_mse_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U8_MIN_MAX, MUI_XY */
|
||||
uint8_t mui_u8g2_u8_min_max_wm_mud_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U8_MIN_MAX, MUI_XY */
|
||||
|
||||
uint8_t mui_u8g2_u8_min_max_wm_mse_pf(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U8_MIN_MAX, MUI_XY */
|
||||
uint8_t mui_u8g2_u8_min_max_wm_mud_pf(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U8_MIN_MAX, MUI_XY */
|
||||
|
||||
/*===== data = mui_u8g2_u8_min_max_step_t* =====*/
|
||||
|
||||
/* gcc note: the macro uses array compound literals to extend the lifetime in C++, see last section in https://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html */
|
||||
#define MUIF_U8G2_U8_MIN_MAX_STEP(id, valptr, min, max, step, flags, muif) \
|
||||
MUIF(id, MUIF_CFLAG_IS_CURSOR_SELECTABLE, \
|
||||
(void *)((mui_u8g2_u8_min_max_step_t [] ) {{ (valptr) MUI_U8G2_COMMA (min) MUI_U8G2_COMMA (max) MUI_U8G2_COMMA (step) MUI_U8G2_COMMA (flags) }}), \
|
||||
(muif))
|
||||
|
||||
#define MUI_MMS_2X_BAR 0x01
|
||||
#define MUI_MMS_4X_BAR 0x02
|
||||
#define MUI_MMS_SHOW_VALUE 0x04
|
||||
|
||||
uint8_t mui_u8g2_u8_bar_wm_mse_pi(mui_t *ui, uint8_t msg);
|
||||
uint8_t mui_u8g2_u8_bar_wm_mud_pi(mui_t *ui, uint8_t msg);
|
||||
uint8_t mui_u8g2_u8_bar_wm_mse_pf(mui_t *ui, uint8_t msg);
|
||||
uint8_t mui_u8g2_u8_bar_wm_mud_pf(mui_t *ui, uint8_t msg);
|
||||
|
||||
/*===== data = mui_u8g2_list_t* =====*/
|
||||
/* similar to mui_u8g2_u8_opt_line, but u16 and dynamic list */
|
||||
|
||||
|
||||
#define MUIF_U8G2_U16_LIST(id, valptr, dataptr, getcb, cntcb, muif) \
|
||||
MUIF(id, MUIF_CFLAG_IS_CURSOR_SELECTABLE, \
|
||||
(void *)((mui_u8g2_list_t [] ) {{ (valptr) MUI_U8G2_COMMA (dataptr) MUI_U8G2_COMMA (getcb) MUI_U8G2_COMMA (cntcb)}}), \
|
||||
(muif))
|
||||
|
||||
uint8_t mui_u8g2_u16_list_line_wa_mse_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U16_LIST, MUI_XYA, arg=pixel fieldsize */
|
||||
uint8_t mui_u8g2_u16_list_line_wa_mud_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U16_LIST, MUI_XYA, arg=pixel fieldsize */
|
||||
|
||||
|
||||
uint8_t mui_u8g2_u16_list_parent_wm_mse_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U16_LIST, MUI_XYA, arg=subform */
|
||||
uint8_t mui_u8g2_u16_list_child_w1_mse_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U16_LIST, MUI_XYA, arg=sub element number */
|
||||
|
||||
uint8_t mui_u8g2_u16_list_goto_w1_mse_pi(mui_t *ui, uint8_t msg); /* REF, MUIF_U8G2_U16_LIST first char of the string denotes the target form */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* MUI_U8G2_H */
|
||||
|
||||
@@ -68,9 +68,16 @@
|
||||
Use 16 Bit mode for any display with more than 240 pixel in one
|
||||
direction.
|
||||
*/
|
||||
#define U8G2_16BIT
|
||||
//#define U8G2_16BIT
|
||||
|
||||
|
||||
/* always enable U8G2_16BIT on 32bit environments, see issue https://github.com/olikraus/u8g2/issues/1222 */
|
||||
#ifndef U8G2_16BIT
|
||||
#if defined(unix) || defined(__unix__) || defined(__arm__) || defined(__xtensa__) || defined(xtensa) || defined(__arc__) || defined(ESP8266) || defined(ESP_PLATFORM) || defined(__LUATOS__)
|
||||
#define U8G2_16BIT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
The following macro switches the library into dynamic display buffer allocation mode.
|
||||
Defining this constant will disable all static memory allocation for device memory buffer and thus allows the user to allocate device buffers statically.
|
||||
@@ -79,7 +86,6 @@
|
||||
*/
|
||||
//#define U8G2_USE_DYNAMIC_ALLOC
|
||||
|
||||
|
||||
/* U8g2 feature selection, see also https://github.com/olikraus/u8g2/wiki/u8g2optimization */
|
||||
|
||||
/*
|
||||
@@ -87,7 +93,9 @@
|
||||
It will consume about 40 bytes more in flash memory of the AVR.
|
||||
HVLine procedures are also used by the text drawing functions.
|
||||
*/
|
||||
#ifndef U8G2_WITHOUT_HVLINE_SPEED_OPTIMIZATION
|
||||
#define U8G2_WITH_HVLINE_SPEED_OPTIMIZATION
|
||||
#endif
|
||||
|
||||
/*
|
||||
The following macro activates the early intersection check with the current visible area.
|
||||
@@ -96,7 +104,9 @@
|
||||
With a full framebuffer in RAM and if most graphical elements are drawn within the visible area, then this
|
||||
macro can be commented to reduce code size.
|
||||
*/
|
||||
#ifndef U8G2_WITHOUT_INTERSECTION
|
||||
#define U8G2_WITH_INTERSECTION
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ -106,7 +116,9 @@
|
||||
Setting a clip window will restrict all drawing to this window.
|
||||
Clip window support requires about 200 bytes flash memory on AVR systems
|
||||
*/
|
||||
#ifndef U8G2_WITHOUT_CLIP_WINDOW_SUPPORT
|
||||
#define U8G2_WITH_CLIP_WINDOW_SUPPORT
|
||||
#endif
|
||||
|
||||
/*
|
||||
The following macro enables all four drawing directions for glyphs and strings.
|
||||
@@ -114,7 +126,9 @@
|
||||
|
||||
Jan 2020: Disabling this macro will save up to 600 bytes on AVR
|
||||
*/
|
||||
#ifndef U8G2_WITHOUT_FONT_ROTATION
|
||||
#define U8G2_WITH_FONT_ROTATION
|
||||
#endif
|
||||
|
||||
/*
|
||||
U8glib V2 contains support for unicode plane 0 (Basic Multilingual Plane, BMP).
|
||||
@@ -140,9 +154,26 @@
|
||||
- C-Code Strings are assumbed to be ISO 8859-1/CP1252 encoded
|
||||
- Only character values 0 to 255 are supported in the font file.
|
||||
*/
|
||||
#ifndef U8G2_WITHOUT_UNICODE
|
||||
#define U8G2_WITH_UNICODE
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
See issue https://github.com/olikraus/u8g2/issues/1561
|
||||
The old behaviour of the StrWidth and UTF8Width functions returned an unbalanced string width, where
|
||||
a small space was added to the left but not to the right of the string in some cases.
|
||||
The new "balanced" procedure will assume the same gap on the left and the right side of the string
|
||||
|
||||
Example: The string width of "C" with font u8g2_font_helvR08_tr was returned as 7.
|
||||
A frame of width 9 would place the C a little bit more to the right (width of that "C" are 6 pixel).
|
||||
If U8G2_BALANCED_STR_WIDTH_CALCULATION is defined, the width of "C" is returned as 8.
|
||||
|
||||
Not defining U8G2_BALANCED_STR_WIDTH_CALCULATION would fall back to the old bahavior.
|
||||
*/
|
||||
#ifndef U8G2_NO_BALANCED_STR_WIDTH_CALCULATION
|
||||
#define U8G2_BALANCED_STR_WIDTH_CALCULATION
|
||||
#endif
|
||||
|
||||
|
||||
/*==========================================*/
|
||||
@@ -159,7 +190,7 @@
|
||||
|
||||
/* the macro U8G2_USE_LARGE_FONTS enables large fonts (>32K) */
|
||||
/* it can be enabled for those uC supporting larger arrays */
|
||||
#if defined(unix) || defined(__arm__) || defined(__arc__) || defined(ESP8266) || defined(ESP_PLATFORM)
|
||||
#if defined(unix) || defined(__unix__) || defined(__arm__) || defined(__arc__) || defined(ESP8266) || defined(ESP_PLATFORM) || defined(__LUATOS__)
|
||||
#ifndef U8G2_USE_LARGE_FONTS
|
||||
#define U8G2_USE_LARGE_FONTS
|
||||
#endif
|
||||
@@ -371,6 +402,7 @@ struct u8g2_struct
|
||||
#define u8g2_SetupDisplay(u8g2, display_cb, cad_cb, byte_cb, gpio_and_delay_cb) \
|
||||
u8x8_Setup(u8g2_GetU8x8(u8g2), (display_cb), (cad_cb), (byte_cb), (gpio_and_delay_cb))
|
||||
|
||||
#define u8g2_InitInterface(u8g2) u8x8_InitInterface(u8g2_GetU8x8(u8g2))
|
||||
#define u8g2_InitDisplay(u8g2) u8x8_InitDisplay(u8g2_GetU8x8(u8g2))
|
||||
#define u8g2_SetPowerSave(u8g2, is_enable) u8x8_SetPowerSave(u8g2_GetU8x8(u8g2), (is_enable))
|
||||
#define u8g2_SetFlipMode(u8g2, mode) u8x8_SetFlipMode(u8g2_GetU8x8(u8g2), (mode))
|
||||
@@ -382,8 +414,8 @@ void u8g2_ClearDisplay(u8g2_t *u8g2);
|
||||
#define u8g2_GetDisplayWidth(u8g2) ((u8g2)->width)
|
||||
#define u8g2_GetDrawColor(u8g2) ((u8g2)->draw_color)
|
||||
|
||||
#define u8g2_SetI2CAddress(u8g2, address) ((u8g2_GetU8x8(u8g2))->i2c_address = (address))
|
||||
#define u8g2_GetI2CAddress(u8g2) u8x8_GetI2CAddress(u8g2_GetU8x8(u8g2))
|
||||
#define u8g2_SetI2CAddress(u8g2, address) ((u8g2_GetU8x8(u8g2))->i2c_address = (address))
|
||||
|
||||
#ifdef U8X8_USE_PINS
|
||||
#define u8g2_SetMenuSelectPin(u8g2, val) u8x8_SetMenuSelectPin(u8g2_GetU8x8(u8g2), (val))
|
||||
@@ -404,12 +436,14 @@ extern const u8g2_cb_t u8g2_cb_r1;
|
||||
extern const u8g2_cb_t u8g2_cb_r2;
|
||||
extern const u8g2_cb_t u8g2_cb_r3;
|
||||
extern const u8g2_cb_t u8g2_cb_mirror;
|
||||
extern const u8g2_cb_t u8g2_cb_mirror_vertical;
|
||||
|
||||
#define U8G2_R0 (&u8g2_cb_r0)
|
||||
#define U8G2_R1 (&u8g2_cb_r1)
|
||||
#define U8G2_R2 (&u8g2_cb_r2)
|
||||
#define U8G2_R3 (&u8g2_cb_r3)
|
||||
#define U8G2_MIRROR (&u8g2_cb_mirror)
|
||||
#define U8G2_MIRROR_VERTICAL (&u8g2_cb_mirror_vertical)
|
||||
/*
|
||||
u8g2: A new, not yet initialized u8g2 memory areay
|
||||
buf: Memory are of size tile_buf_height*<width of the display in pixel>
|
||||
@@ -455,6 +489,9 @@ uint8_t *u8g2_m_8_16_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_12_12_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_12_12_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_12_12_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_10_16_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_10_16_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_10_16_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_16_16_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_16_16_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_16_16_f(uint8_t *page_cnt);
|
||||
@@ -464,6 +501,9 @@ uint8_t *u8g2_m_20_20_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_32_8_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_32_8_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_32_8_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_13_8_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_13_8_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_13_8_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_8_6_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_8_6_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_8_6_f(uint8_t *page_cnt);
|
||||
@@ -491,9 +531,6 @@ uint8_t *u8g2_m_50_30_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_18_21_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_18_21_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_18_21_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_13_8_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_13_8_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_13_8_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_11_6_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_11_6_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_11_6_f(uint8_t *page_cnt);
|
||||
@@ -515,15 +552,24 @@ uint8_t *u8g2_m_30_16_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_16_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_16_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_16_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_24_12_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_24_12_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_24_12_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_13_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_13_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_13_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_30_20_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_30_20_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_30_20_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_32_16_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_32_16_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_32_16_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_40_30_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_40_30_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_40_30_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_8_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_8_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_8_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_17_4_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_17_4_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_17_4_f(uint8_t *page_cnt);
|
||||
@@ -533,21 +579,27 @@ uint8_t *u8g2_m_17_8_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_48_17_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_48_17_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_48_17_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_32_16_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_32_16_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_32_16_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_12_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_12_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_12_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_32_20_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_32_20_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_32_20_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_22_13_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_22_13_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_22_13_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_24_12_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_24_12_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_24_12_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_19_4_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_19_4_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_19_4_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_10_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_10_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_10_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_4_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_4_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_4_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_17_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_17_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_20_17_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_22_9_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_22_9_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_22_9_f(uint8_t *page_cnt);
|
||||
@@ -587,11 +639,17 @@ void u8g2_Setup_ssd1305_i2c_128x32_adafruit_2(u8g2_t *u8g2, const u8g2_cb_t *rot
|
||||
void u8g2_Setup_ssd1305_i2c_128x32_noname_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1305_i2c_128x32_adafruit_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1305_128x64_adafruit_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1305_128x64_raystar_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1305_128x64_adafruit_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1305_128x64_raystar_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1305_128x64_adafruit_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1305_128x64_raystar_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1305_i2c_128x64_adafruit_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1305_i2c_128x64_raystar_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1305_i2c_128x64_adafruit_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1305_i2c_128x64_raystar_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1305_i2c_128x64_adafruit_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1305_i2c_128x64_raystar_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1306_2040x16_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1306_2040x16_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1306_2040x16_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
@@ -661,6 +719,12 @@ void u8g2_Setup_sh1107_seeed_96x96_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8
|
||||
void u8g2_Setup_sh1107_i2c_seeed_96x96_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1107_i2c_seeed_96x96_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1107_i2c_seeed_96x96_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1107_128x80_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1107_128x80_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1107_128x80_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1107_i2c_128x80_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1107_i2c_128x80_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1107_i2c_128x80_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1107_128x128_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1107_pimoroni_128x128_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1107_seeed_128x128_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
@@ -703,6 +767,18 @@ void u8g2_Setup_ssd1306_i2c_128x32_univision_2(u8g2_t *u8g2, const u8g2_cb_t *ro
|
||||
void u8g2_Setup_ssd1306_i2c_128x32_winstar_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1306_i2c_128x32_univision_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1306_i2c_128x32_winstar_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1306_102x64_ea_oleds102_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1306_102x64_ea_oleds102_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1306_102x64_ea_oleds102_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1306_i2c_102x64_ea_oleds102_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1306_i2c_102x64_ea_oleds102_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1306_i2c_102x64_ea_oleds102_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1106_128x32_visionox_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1106_128x32_visionox_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1106_128x32_visionox_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1106_i2c_128x32_visionox_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1106_i2c_128x32_visionox_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_sh1106_i2c_128x32_visionox_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1306_64x48_er_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1306_64x48_er_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1306_64x48_er_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
@@ -826,12 +902,30 @@ void u8g2_Setup_ssd1327_i2c_visionox_128x96_f(u8g2_t *u8g2, const u8g2_cb_t *rot
|
||||
void u8g2_Setup_ssd1329_128x96_noname_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1329_128x96_noname_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1329_128x96_noname_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1329_96x96_noname_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1329_96x96_noname_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1329_96x96_noname_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ld7032_60x32_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ld7032_60x32_alt_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ld7032_60x32_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ld7032_60x32_alt_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ld7032_60x32_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ld7032_60x32_alt_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ld7032_i2c_60x32_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ld7032_i2c_60x32_alt_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ld7032_i2c_60x32_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ld7032_i2c_60x32_alt_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ld7032_i2c_60x32_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ld7032_i2c_60x32_alt_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7920_p_256x32_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7920_p_256x32_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7920_p_256x32_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7920_256x32_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7920_256x32_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7920_256x32_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7920_s_256x32_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7920_s_256x32_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7920_s_256x32_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7920_p_192x32_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7920_p_192x32_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7920_p_192x32_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
@@ -854,8 +948,11 @@ void u8g2_Setup_ls013b7dh03_128x128_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u
|
||||
void u8g2_Setup_ls013b7dh03_128x128_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ls013b7dh03_128x128_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ls027b7dh01_400x240_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ls027b7dh01_m0_400x240_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ls027b7dh01_400x240_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ls027b7dh01_m0_400x240_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ls027b7dh01_400x240_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ls027b7dh01_m0_400x240_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ls013b7dh05_144x168_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ls013b7dh05_144x168_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ls013b7dh05_144x168_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
@@ -904,9 +1001,21 @@ void u8g2_Setup_uc1608_240x128_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_m
|
||||
void u8g2_Setup_uc1608_i2c_240x128_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1608_i2c_240x128_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1608_i2c_240x128_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1609_slg19264_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1609_slg19264_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1609_slg19264_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1609_i2c_slg19264_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1609_i2c_slg19264_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1609_i2c_slg19264_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1638_160x128_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1638_160x128_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1638_160x128_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1638_192x96_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1638_192x96_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1638_192x96_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1638_i2c_192x96_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1638_i2c_192x96_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1638_i2c_192x96_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1610_ea_dogxl160_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1610_ea_dogxl160_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1610_ea_dogxl160_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
@@ -937,6 +1046,12 @@ void u8g2_Setup_uc1611_cg160160_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_
|
||||
void u8g2_Setup_uc1611_i2c_cg160160_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1611_i2c_cg160160_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1611_i2c_cg160160_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1611_ids4073_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1611_ids4073_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1611_ids4073_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1611_i2c_ids4073_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1611_i2c_ids4073_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1611_i2c_ids4073_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7511_avd_320x240_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7511_avd_320x240_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7511_avd_320x240_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
@@ -946,6 +1061,12 @@ void u8g2_Setup_st7528_nhd_c160100_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8
|
||||
void u8g2_Setup_st7528_i2c_nhd_c160100_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7528_i2c_nhd_c160100_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7528_i2c_nhd_c160100_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7528_erc16064_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7528_erc16064_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7528_erc16064_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7528_i2c_erc16064_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7528_i2c_erc16064_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7528_i2c_erc16064_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1617_jlx128128_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1617_jlx128128_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1617_jlx128128_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
@@ -994,6 +1115,12 @@ void u8g2_Setup_uc1601_128x32_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_ms
|
||||
void u8g2_Setup_uc1601_i2c_128x32_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1601_i2c_128x32_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1601_i2c_128x32_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1601_128x64_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1601_128x64_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1601_128x64_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1601_i2c_128x64_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1601_i2c_128x64_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_uc1601_i2c_128x64_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7565_ea_dogm132_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7565_ea_dogm132_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7565_ea_dogm132_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
@@ -1018,24 +1145,42 @@ void u8g2_Setup_st7567_64x32_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg
|
||||
void u8g2_Setup_st7567_hem6432_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7567_64x32_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7567_hem6432_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7567_i2c_64x32_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7567_i2c_hem6432_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7567_i2c_64x32_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7567_i2c_hem6432_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7567_i2c_64x32_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7567_i2c_hem6432_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7567_122x32_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7567_122x32_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7567_122x32_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7571_128x128_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7571_128x128_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7571_128x128_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7571_i2c_128x128_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7571_i2c_128x128_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7571_i2c_128x128_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7571_128x96_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7571_128x96_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7571_128x96_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7571_i2c_128x96_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7571_i2c_128x96_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7571_i2c_128x96_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7586s_s028hn118a_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7586s_s028hn118a_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7586s_s028hn118a_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7586s_erc240160_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7586s_ymc240160_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7586s_erc240160_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7586s_ymc240160_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7586s_erc240160_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7586s_ymc240160_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7588_jlx12864_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7588_jlx12864_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7588_jlx12864_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7588_i2c_jlx12864_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7588_i2c_jlx12864_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st7588_i2c_jlx12864_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st75160_jm16096_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st75160_jm16096_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st75160_jm16096_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st75160_i2c_jm16096_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st75160_i2c_jm16096_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st75160_i2c_jm16096_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st75256_jlx256128_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st75256_wo256x128_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_st75256_jlx256128_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
@@ -1117,6 +1262,12 @@ void u8g2_Setup_ks0108_128x64_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_ms
|
||||
void u8g2_Setup_ks0108_erm19264_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ks0108_erm19264_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ks0108_erm19264_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_t7932_150x32_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_t7932_150x32_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_t7932_150x32_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_hd44102_100x64_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_hd44102_100x64_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_hd44102_100x64_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_lc7981_160x80_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_lc7981_160x80_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_lc7981_160x80_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
@@ -1147,6 +1298,12 @@ void u8g2_Setup_t6963_128x64_alt_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8
|
||||
void u8g2_Setup_t6963_160x80_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_t6963_160x80_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_t6963_160x80_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1320_160x32_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1320_160x32_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1320_160x32_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1320_160x132_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1320_160x132_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1320_160x132_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1322_nhd_256x64_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1322_nhd_256x64_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_ssd1322_nhd_256x64_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
@@ -1189,6 +1346,15 @@ void u8g2_Setup_max7219_32x8_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg
|
||||
void u8g2_Setup_max7219_8x8_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_max7219_8x8_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_max7219_8x8_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_s1d15e06_160100_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_s1d15e06_160100_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_s1d15e06_160100_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_s1d15721_240x64_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_s1d15721_240x64_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_s1d15721_240x64_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_gu800_128x64_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_gu800_128x64_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_gu800_128x64_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_a2printer_384x240_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_a2printer_384x240_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_a2printer_384x240_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
@@ -1206,6 +1372,11 @@ void u8g2_SetBufferCurrTileRow(u8g2_t *u8g2, uint8_t row) U8G2_NOINLINE;
|
||||
void u8g2_FirstPage(u8g2_t *u8g2);
|
||||
uint8_t u8g2_NextPage(u8g2_t *u8g2);
|
||||
|
||||
// Add ability to set buffer pointer
|
||||
#ifdef __ARM_LINUX__
|
||||
#define U8G2_USE_DYNAMIC_ALLOC
|
||||
#endif
|
||||
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
#define u8g2_SetBufferPtr(u8g2, buf) ((u8g2)->tile_buf_ptr = (buf));
|
||||
#define u8g2_GetBufferSize(u8g2) ((u8g2)->u8x8.display_info->tile_width * 8 * (u8g2)->tile_buf_height)
|
||||
@@ -1299,6 +1470,36 @@ void u8g2_DrawFrame(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u
|
||||
void u8g2_DrawRBox(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, u8g2_uint_t r);
|
||||
void u8g2_DrawRFrame(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, u8g2_uint_t r);
|
||||
|
||||
/*==========================================*/
|
||||
/* u8g2_button.c */
|
||||
|
||||
/* border width */
|
||||
#define U8G2_BTN_BW_POS 0
|
||||
#define U8G2_BTN_BW_MASK 7
|
||||
#define U8G2_BTN_BW0 0x00
|
||||
#define U8G2_BTN_BW1 0x01
|
||||
#define U8G2_BTN_BW2 0x02
|
||||
#define U8G2_BTN_BW3 0x03
|
||||
|
||||
/* enable shadow and define gap to button */
|
||||
#define U8G2_BTN_SHADOW_POS 3
|
||||
#define U8G2_BTN_SHADOW_MASK 0x18
|
||||
#define U8G2_BTN_SHADOW0 0x08
|
||||
#define U8G2_BTN_SHADOW1 0x10
|
||||
#define U8G2_BTN_SHADOW2 0x18
|
||||
|
||||
/* text is displayed inverted */
|
||||
#define U8G2_BTN_INV 0x20
|
||||
|
||||
/* horizontal center */
|
||||
#define U8G2_BTN_HCENTER 0x40
|
||||
|
||||
/* second one pixel frame */
|
||||
#define U8G2_BTN_XFRAME 0x80
|
||||
|
||||
void u8g2_DrawButtonFrame(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t flags, u8g2_uint_t text_width, u8g2_uint_t padding_h, u8g2_uint_t padding_v);
|
||||
void u8g2_DrawButtonUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t flags, u8g2_uint_t width, u8g2_uint_t padding_h, u8g2_uint_t padding_v, const char *text);
|
||||
|
||||
|
||||
/*==========================================*/
|
||||
/* u8g2_polygon.c */
|
||||
@@ -1354,6 +1555,8 @@ uint8_t u8g2_IsAllValidUTF8(u8g2_t *u8g2, const char *str); // checks whether al
|
||||
|
||||
u8g2_uint_t u8g2_GetStrWidth(u8g2_t *u8g2, const char *s);
|
||||
u8g2_uint_t u8g2_GetUTF8Width(u8g2_t *u8g2, const char *str);
|
||||
/*u8g2_uint_t u8g2_GetExactStrWidth(u8g2_t *u8g2, const char *s);*/ /*obsolete, see also https://github.com/olikraus/u8g2/issues/1561 */
|
||||
|
||||
|
||||
void u8g2_SetFontPosBaseline(u8g2_t *u8g2);
|
||||
void u8g2_SetFontPosBottom(u8g2_t *u8g2);
|
||||
@@ -1427,6 +1630,16 @@ extern const uint8_t u8g2_font_m2icon_7_tf[] U8G2_FONT_SECTION("u8g2_font_m2icon
|
||||
extern const uint8_t u8g2_font_m2icon_9_tf[] U8G2_FONT_SECTION("u8g2_font_m2icon_9_tf");
|
||||
extern const uint8_t u8g2_font_emoticons21_tr[] U8G2_FONT_SECTION("u8g2_font_emoticons21_tr");
|
||||
extern const uint8_t u8g2_font_battery19_tn[] U8G2_FONT_SECTION("u8g2_font_battery19_tn");
|
||||
extern const uint8_t u8g2_font_battery24_tr[] U8G2_FONT_SECTION("u8g2_font_battery24_tr");
|
||||
extern const uint8_t u8g2_font_squeezed_r6_tr[] U8G2_FONT_SECTION("u8g2_font_squeezed_r6_tr");
|
||||
extern const uint8_t u8g2_font_squeezed_r6_tn[] U8G2_FONT_SECTION("u8g2_font_squeezed_r6_tn");
|
||||
extern const uint8_t u8g2_font_squeezed_b6_tr[] U8G2_FONT_SECTION("u8g2_font_squeezed_b6_tr");
|
||||
extern const uint8_t u8g2_font_squeezed_b6_tn[] U8G2_FONT_SECTION("u8g2_font_squeezed_b6_tn");
|
||||
extern const uint8_t u8g2_font_squeezed_r7_tr[] U8G2_FONT_SECTION("u8g2_font_squeezed_r7_tr");
|
||||
extern const uint8_t u8g2_font_squeezed_r7_tn[] U8G2_FONT_SECTION("u8g2_font_squeezed_r7_tn");
|
||||
extern const uint8_t u8g2_font_squeezed_b7_tr[] U8G2_FONT_SECTION("u8g2_font_squeezed_b7_tr");
|
||||
extern const uint8_t u8g2_font_squeezed_b7_tn[] U8G2_FONT_SECTION("u8g2_font_squeezed_b7_tn");
|
||||
extern const uint8_t u8g2_font_percent_circle_25_hn[] U8G2_FONT_SECTION("u8g2_font_percent_circle_25_hn");
|
||||
extern const uint8_t u8g2_font_freedoomr10_tu[] U8G2_FONT_SECTION("u8g2_font_freedoomr10_tu");
|
||||
extern const uint8_t u8g2_font_freedoomr10_mu[] U8G2_FONT_SECTION("u8g2_font_freedoomr10_mu");
|
||||
extern const uint8_t u8g2_font_freedoomr25_tn[] U8G2_FONT_SECTION("u8g2_font_freedoomr25_tn");
|
||||
@@ -1603,6 +1816,7 @@ extern const uint8_t u8g2_font_10x20_t_greek[] U8G2_FONT_SECTION("u8g2_font_10x2
|
||||
extern const uint8_t u8g2_font_10x20_t_cyrillic[] U8G2_FONT_SECTION("u8g2_font_10x20_t_cyrillic");
|
||||
extern const uint8_t u8g2_font_10x20_t_arabic[] U8G2_FONT_SECTION("u8g2_font_10x20_t_arabic");
|
||||
extern const uint8_t u8g2_font_siji_t_6x10[] U8G2_FONT_SECTION("u8g2_font_siji_t_6x10");
|
||||
extern const uint8_t u8g2_font_waffle_t_all[] U8G2_FONT_SECTION("u8g2_font_waffle_t_all");
|
||||
extern const uint8_t u8g2_font_tom_thumb_4x6_t_all[] U8G2_FONT_SECTION("u8g2_font_tom_thumb_4x6_t_all");
|
||||
extern const uint8_t u8g2_font_tom_thumb_4x6_tf[] U8G2_FONT_SECTION("u8g2_font_tom_thumb_4x6_tf");
|
||||
extern const uint8_t u8g2_font_tom_thumb_4x6_tr[] U8G2_FONT_SECTION("u8g2_font_tom_thumb_4x6_tr");
|
||||
@@ -1832,6 +2046,66 @@ extern const uint8_t u8g2_font_open_iconic_text_8x_t[] U8G2_FONT_SECTION("u8g2_f
|
||||
extern const uint8_t u8g2_font_open_iconic_thing_8x_t[] U8G2_FONT_SECTION("u8g2_font_open_iconic_thing_8x_t");
|
||||
extern const uint8_t u8g2_font_open_iconic_weather_8x_t[] U8G2_FONT_SECTION("u8g2_font_open_iconic_weather_8x_t");
|
||||
extern const uint8_t u8g2_font_open_iconic_www_8x_t[] U8G2_FONT_SECTION("u8g2_font_open_iconic_www_8x_t");
|
||||
extern const uint8_t u8g2_font_streamline_all_t[] U8G2_FONT_SECTION("u8g2_font_streamline_all_t");
|
||||
extern const uint8_t u8g2_font_streamline_building_real_estate_t[] U8G2_FONT_SECTION("u8g2_font_streamline_building_real_estate_t");
|
||||
extern const uint8_t u8g2_font_streamline_business_t[] U8G2_FONT_SECTION("u8g2_font_streamline_business_t");
|
||||
extern const uint8_t u8g2_font_streamline_coding_apps_websites_t[] U8G2_FONT_SECTION("u8g2_font_streamline_coding_apps_websites_t");
|
||||
extern const uint8_t u8g2_font_streamline_computers_devices_electronics_t[] U8G2_FONT_SECTION("u8g2_font_streamline_computers_devices_electronics_t");
|
||||
extern const uint8_t u8g2_font_streamline_content_files_t[] U8G2_FONT_SECTION("u8g2_font_streamline_content_files_t");
|
||||
extern const uint8_t u8g2_font_streamline_design_t[] U8G2_FONT_SECTION("u8g2_font_streamline_design_t");
|
||||
extern const uint8_t u8g2_font_streamline_ecology_t[] U8G2_FONT_SECTION("u8g2_font_streamline_ecology_t");
|
||||
extern const uint8_t u8g2_font_streamline_email_t[] U8G2_FONT_SECTION("u8g2_font_streamline_email_t");
|
||||
extern const uint8_t u8g2_font_streamline_entertainment_events_hobbies_t[] U8G2_FONT_SECTION("u8g2_font_streamline_entertainment_events_hobbies_t");
|
||||
extern const uint8_t u8g2_font_streamline_food_drink_t[] U8G2_FONT_SECTION("u8g2_font_streamline_food_drink_t");
|
||||
extern const uint8_t u8g2_font_streamline_hand_signs_t[] U8G2_FONT_SECTION("u8g2_font_streamline_hand_signs_t");
|
||||
extern const uint8_t u8g2_font_streamline_health_beauty_t[] U8G2_FONT_SECTION("u8g2_font_streamline_health_beauty_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_action_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_action_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_alert_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_alert_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_audio_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_audio_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_calendar_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_calendar_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_chart_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_chart_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_circle_triangle_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_circle_triangle_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_cog_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_cog_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_cursor_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_cursor_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_dial_pad_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_dial_pad_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_edit_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_edit_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_expand_shrink_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_expand_shrink_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_eye_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_eye_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_file_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_file_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_help_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_help_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_hierarchy_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_hierarchy_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_home_menu_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_home_menu_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_id_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_id_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_key_lock_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_key_lock_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_link_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_link_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_loading_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_loading_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_login_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_login_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_other_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_other_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_paginate_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_paginate_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_search_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_search_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_setting_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_setting_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_share_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_share_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_text_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_text_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_wifi_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_wifi_t");
|
||||
extern const uint8_t u8g2_font_streamline_interface_essential_zoom_t[] U8G2_FONT_SECTION("u8g2_font_streamline_interface_essential_zoom_t");
|
||||
extern const uint8_t u8g2_font_streamline_internet_network_t[] U8G2_FONT_SECTION("u8g2_font_streamline_internet_network_t");
|
||||
extern const uint8_t u8g2_font_streamline_logo_t[] U8G2_FONT_SECTION("u8g2_font_streamline_logo_t");
|
||||
extern const uint8_t u8g2_font_streamline_map_navigation_t[] U8G2_FONT_SECTION("u8g2_font_streamline_map_navigation_t");
|
||||
extern const uint8_t u8g2_font_streamline_money_payments_t[] U8G2_FONT_SECTION("u8g2_font_streamline_money_payments_t");
|
||||
extern const uint8_t u8g2_font_streamline_music_audio_t[] U8G2_FONT_SECTION("u8g2_font_streamline_music_audio_t");
|
||||
extern const uint8_t u8g2_font_streamline_pet_animals_t[] U8G2_FONT_SECTION("u8g2_font_streamline_pet_animals_t");
|
||||
extern const uint8_t u8g2_font_streamline_phone_t[] U8G2_FONT_SECTION("u8g2_font_streamline_phone_t");
|
||||
extern const uint8_t u8g2_font_streamline_photography_t[] U8G2_FONT_SECTION("u8g2_font_streamline_photography_t");
|
||||
extern const uint8_t u8g2_font_streamline_romance_t[] U8G2_FONT_SECTION("u8g2_font_streamline_romance_t");
|
||||
extern const uint8_t u8g2_font_streamline_school_science_t[] U8G2_FONT_SECTION("u8g2_font_streamline_school_science_t");
|
||||
extern const uint8_t u8g2_font_streamline_shopping_shipping_t[] U8G2_FONT_SECTION("u8g2_font_streamline_shopping_shipping_t");
|
||||
extern const uint8_t u8g2_font_streamline_social_rewards_t[] U8G2_FONT_SECTION("u8g2_font_streamline_social_rewards_t");
|
||||
extern const uint8_t u8g2_font_streamline_technology_t[] U8G2_FONT_SECTION("u8g2_font_streamline_technology_t");
|
||||
extern const uint8_t u8g2_font_streamline_transportation_t[] U8G2_FONT_SECTION("u8g2_font_streamline_transportation_t");
|
||||
extern const uint8_t u8g2_font_streamline_travel_wayfinding_t[] U8G2_FONT_SECTION("u8g2_font_streamline_travel_wayfinding_t");
|
||||
extern const uint8_t u8g2_font_streamline_users_t[] U8G2_FONT_SECTION("u8g2_font_streamline_users_t");
|
||||
extern const uint8_t u8g2_font_streamline_video_movies_t[] U8G2_FONT_SECTION("u8g2_font_streamline_video_movies_t");
|
||||
extern const uint8_t u8g2_font_streamline_weather_t[] U8G2_FONT_SECTION("u8g2_font_streamline_weather_t");
|
||||
extern const uint8_t u8g2_font_profont10_tf[] U8G2_FONT_SECTION("u8g2_font_profont10_tf");
|
||||
extern const uint8_t u8g2_font_profont10_tr[] U8G2_FONT_SECTION("u8g2_font_profont10_tr");
|
||||
extern const uint8_t u8g2_font_profont10_tn[] U8G2_FONT_SECTION("u8g2_font_profont10_tn");
|
||||
@@ -2817,6 +3091,19 @@ extern const uint8_t u8g2_font_lucasarts_scumm_subtitle_o_tn[] U8G2_FONT_SECTION
|
||||
extern const uint8_t u8g2_font_lucasarts_scumm_subtitle_r_tf[] U8G2_FONT_SECTION("u8g2_font_lucasarts_scumm_subtitle_r_tf");
|
||||
extern const uint8_t u8g2_font_lucasarts_scumm_subtitle_r_tr[] U8G2_FONT_SECTION("u8g2_font_lucasarts_scumm_subtitle_r_tr");
|
||||
extern const uint8_t u8g2_font_lucasarts_scumm_subtitle_r_tn[] U8G2_FONT_SECTION("u8g2_font_lucasarts_scumm_subtitle_r_tn");
|
||||
extern const uint8_t u8g2_font_utopia24_tf[] U8G2_FONT_SECTION("u8g2_font_utopia24_tf");
|
||||
extern const uint8_t u8g2_font_utopia24_tr[] U8G2_FONT_SECTION("u8g2_font_utopia24_tr");
|
||||
extern const uint8_t u8g2_font_utopia24_tn[] U8G2_FONT_SECTION("u8g2_font_utopia24_tn");
|
||||
extern const uint8_t u8g2_font_utopia24_te[] U8G2_FONT_SECTION("u8g2_font_utopia24_te");
|
||||
extern const uint8_t u8g2_font_m_c_kids_nes_credits_font_tr[] U8G2_FONT_SECTION("u8g2_font_m_c_kids_nes_credits_font_tr");
|
||||
extern const uint8_t u8g2_font_chargen_92_tf[] U8G2_FONT_SECTION("u8g2_font_chargen_92_tf");
|
||||
extern const uint8_t u8g2_font_chargen_92_tr[] U8G2_FONT_SECTION("u8g2_font_chargen_92_tr");
|
||||
extern const uint8_t u8g2_font_chargen_92_tn[] U8G2_FONT_SECTION("u8g2_font_chargen_92_tn");
|
||||
extern const uint8_t u8g2_font_chargen_92_te[] U8G2_FONT_SECTION("u8g2_font_chargen_92_te");
|
||||
extern const uint8_t u8g2_font_chargen_92_mf[] U8G2_FONT_SECTION("u8g2_font_chargen_92_mf");
|
||||
extern const uint8_t u8g2_font_chargen_92_mr[] U8G2_FONT_SECTION("u8g2_font_chargen_92_mr");
|
||||
extern const uint8_t u8g2_font_chargen_92_mn[] U8G2_FONT_SECTION("u8g2_font_chargen_92_mn");
|
||||
extern const uint8_t u8g2_font_chargen_92_me[] U8G2_FONT_SECTION("u8g2_font_chargen_92_me");
|
||||
extern const uint8_t u8g2_font_fub11_tf[] U8G2_FONT_SECTION("u8g2_font_fub11_tf");
|
||||
extern const uint8_t u8g2_font_fub11_tr[] U8G2_FONT_SECTION("u8g2_font_fub11_tr");
|
||||
extern const uint8_t u8g2_font_fub11_tn[] U8G2_FONT_SECTION("u8g2_font_fub11_tn");
|
||||
|
||||
313
MilliOhmMeter_FW/lib/U8g2/src/clib/u8g2_button.c
Normal file
313
MilliOhmMeter_FW/lib/U8g2/src/clib/u8g2_button.c
Normal file
@@ -0,0 +1,313 @@
|
||||
/*
|
||||
|
||||
u8g2_button.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g2.h"
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Description:
|
||||
Draws normal or inverted text with optional frame around text.
|
||||
The text (and the frame) can be horizontally centered around the provided reference position.
|
||||
This procedure will use the current draw color and current font. The height of the frame
|
||||
depends on the setting of setFontRefHeightText(), setFontRefHeightExtendedText() or setFontRefHeightAll()
|
||||
|
||||
|
||||
Note 1: drawColor 2 (XOR) is not supported. Result will be broken with draw color 2.
|
||||
Note 2: This procedure will enforce font mode 1 (transparent mode)
|
||||
Note 3: Some fonts may add an extra gap on the right side. This is a font problem and can not be avoided (for example inb16 has this problem).
|
||||
|
||||
|
||||
The height of the button is defined by the current font and
|
||||
setFontRefHeightText,
|
||||
setFontRefHeightExtendedText
|
||||
setFontRefHeightAll
|
||||
Right padding might be influenced by the font.
|
||||
For example u8g2_font_inb16 may add an extra pixel gap (increase padding by one)
|
||||
on the right side.
|
||||
The current draw color is considered, but only draw color 0 and 1 are supported
|
||||
|
||||
This function requires transparent font mode: setFontMode(1)
|
||||
|
||||
Side effect: Font transparent mode is enabled setFontMode(1)
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
flags:
|
||||
|
||||
U8G2_BTN_BW1 0x01
|
||||
U8G2_BTN_BW2 0x02
|
||||
U8G2_BTN_BW3 0x03
|
||||
|
||||
|
||||
U8G2_BTN_SHADOW0 0x08
|
||||
U8G2_BTN_SHADOW1 0x10
|
||||
U8G2_BTN_SHADOW2 0x18
|
||||
|
||||
U8G2_BTN_INV 0x20
|
||||
|
||||
U8G2_BTN_HCENTER 0x40
|
||||
|
||||
U8G2_BTN_XFRAME 0x80
|
||||
|
||||
Total size without shadow: width+2*padding_h+2*border
|
||||
Total size with U8G2_BTN_SHADOW0: width+2*padding_h+3*border
|
||||
Total size with U8G2_BTN_SHADOW1: width+2*padding_h+3*border+1
|
||||
Total size with U8G2_BTN_SHADOW2: width+2*padding_h+3*border+2
|
||||
|
||||
U8G2_BTN_XFRAME:
|
||||
draw another one pixel frame with one pixel gap, will not look good with shadow
|
||||
*/
|
||||
|
||||
void u8g2_DrawButtonFrame(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t flags, u8g2_uint_t text_width, u8g2_uint_t padding_h, u8g2_uint_t padding_v)
|
||||
{
|
||||
u8g2_uint_t w = text_width;
|
||||
|
||||
u8g2_uint_t xx, yy, ww, hh;
|
||||
|
||||
u8g2_uint_t gap_frame = U8G2_BTN_BW_MASK+1;
|
||||
|
||||
u8g2_uint_t border_width = flags & U8G2_BTN_BW_MASK;
|
||||
|
||||
int8_t a = u8g2_GetAscent(u8g2);
|
||||
int8_t d = u8g2_GetDescent(u8g2);
|
||||
|
||||
uint8_t color_backup = u8g2->draw_color;
|
||||
|
||||
|
||||
if ( flags & U8G2_BTN_XFRAME )
|
||||
{
|
||||
border_width++;
|
||||
gap_frame = border_width;
|
||||
border_width++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
for(;;)
|
||||
{
|
||||
|
||||
xx = x;
|
||||
xx -= padding_h;
|
||||
xx -= border_width;
|
||||
ww = w+2*padding_h+2*border_width;
|
||||
|
||||
yy = y;
|
||||
yy += u8g2->font_calc_vref(u8g2);
|
||||
yy -= a;
|
||||
yy -= padding_v;
|
||||
yy -= border_width;
|
||||
hh = a-d+2*padding_v+2*border_width;
|
||||
if ( border_width == 0 )
|
||||
break;
|
||||
if ( border_width == gap_frame )
|
||||
{
|
||||
u8g2_SetDrawColor(u8g2, color_backup == 0 ? 1 : 0);
|
||||
}
|
||||
u8g2_DrawFrame(u8g2, xx, yy, ww, hh);
|
||||
u8g2_SetDrawColor(u8g2, color_backup);
|
||||
|
||||
if ( flags & U8G2_BTN_SHADOW_MASK )
|
||||
{
|
||||
if ( border_width == (flags & U8G2_BTN_BW_MASK) )
|
||||
{
|
||||
u8g2_uint_t i;
|
||||
u8g2_uint_t shadow_gap = (flags & U8G2_BTN_SHADOW_MASK) >> U8G2_BTN_SHADOW_POS;
|
||||
shadow_gap--;
|
||||
for( i = 0; i < border_width; i++ )
|
||||
{
|
||||
u8g2_DrawHLine(u8g2, xx+border_width+shadow_gap,yy+hh+i+shadow_gap,ww);
|
||||
u8g2_DrawVLine(u8g2, xx+ww+i+shadow_gap,yy+border_width+shadow_gap,hh);
|
||||
}
|
||||
}
|
||||
}
|
||||
border_width--;
|
||||
} /* for */
|
||||
|
||||
if ( flags & U8G2_BTN_INV )
|
||||
{
|
||||
u8g2_SetDrawColor(u8g2, 2); /* XOR */
|
||||
u8g2_DrawBox(u8g2, xx, yy, ww, hh);
|
||||
u8g2_SetDrawColor(u8g2, color_backup);
|
||||
}
|
||||
}
|
||||
|
||||
void u8g2_DrawButtonUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t flags, u8g2_uint_t width, u8g2_uint_t padding_h, u8g2_uint_t padding_v, const char *text)
|
||||
{
|
||||
u8g2_uint_t w = u8g2_GetUTF8Width(u8g2, text);
|
||||
|
||||
u8g2_uint_t text_x_offset = 0;
|
||||
|
||||
if ( flags & U8G2_BTN_HCENTER )
|
||||
x -= (w+1)/2;
|
||||
|
||||
if ( w < width )
|
||||
{
|
||||
if ( flags & U8G2_BTN_HCENTER )
|
||||
{
|
||||
text_x_offset = (width-w)/2;
|
||||
}
|
||||
w = width;
|
||||
}
|
||||
|
||||
u8g2_SetFontMode(u8g2, 1);
|
||||
u8g2_DrawUTF8(u8g2, x,y, text);
|
||||
u8g2_DrawButtonFrame(u8g2, x-text_x_offset, y, flags, w, padding_h, padding_v);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef NOT_USED
|
||||
void u8g2_Draw4Pixel(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w)
|
||||
{
|
||||
u8g2_DrawPixel(u8g2, x,y-1);
|
||||
u8g2_DrawPixel(u8g2, x+w-1,y-1);
|
||||
u8g2_DrawPixel(u8g2, x+w-1,y-w);
|
||||
u8g2_DrawPixel(u8g2, x,y-w);
|
||||
}
|
||||
|
||||
void u8g2_DrawRadio(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t is_checked)
|
||||
{
|
||||
uint8_t color_backup = u8g2->draw_color;
|
||||
u8g2_DrawCheckbox(u8g2, x,y,w,is_checked);
|
||||
u8g2_SetDrawColor(u8g2, 2);
|
||||
u8g2_Draw4Pixel(u8g2, x,y,w);
|
||||
if ( is_checked )
|
||||
{
|
||||
//u8g2_Draw4Pixel(u8g2, x+2,y-2,w-4);
|
||||
}
|
||||
|
||||
u8g2_SetDrawColor(u8g2, color_backup );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _THIS_CODE_SHOULD_BE_REWRITTEN_WITHOUT_PADWIDTH_
|
||||
|
||||
/*
|
||||
Shadow is not supported
|
||||
Note: radius must be at least as high as the border width
|
||||
|
||||
border width | good radius values
|
||||
1 | 3, 5, 7, 8, ...
|
||||
2 | 3, 5, 7, 8, ...
|
||||
|
||||
*/
|
||||
|
||||
void u8g2_DrawRButtonUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t flags, u8g2_uint_t padding_h_or_width, u8g2_uint_t padding_v, u8g2_uint_t r, const char *text)
|
||||
{
|
||||
u8g2_uint_t w = u8g2_GetUTF8Width(u8g2, text);
|
||||
//u8g2_uint_t w = u8g2_GetExactStrWidth(u8g2, text);
|
||||
|
||||
u8g2_uint_t xx, yy, ww, hh;
|
||||
|
||||
u8g2_uint_t border_width = flags & U8G2_BTN_BW_MASK;
|
||||
u8g2_uint_t padding_h = padding_h_or_width;
|
||||
u8g2_uint_t text_x_offset = 0; // used for U8G2_BTN_PADWIDTH mode
|
||||
|
||||
int8_t a = u8g2_GetAscent(u8g2);
|
||||
int8_t d = u8g2_GetDescent(u8g2);
|
||||
uint8_t color_backup = u8g2->draw_color;
|
||||
|
||||
|
||||
if ( flags & U8G2_BTN_HCENTER )
|
||||
x -= w/2;
|
||||
|
||||
if ( flags & U8G2_BTN_PADWIDTH )
|
||||
{
|
||||
padding_h = 0;
|
||||
if ( w < padding_h_or_width )
|
||||
{
|
||||
if ( flags & U8G2_BTN_HCENTER )
|
||||
{
|
||||
text_x_offset = (padding_h_or_width-w)/2;
|
||||
}
|
||||
w = padding_h_or_width;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
u8g2_SetFontMode(u8g2, 1);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
if ( padding_h >= u8g2_GetDisplayWidth(u8g2)/2 ) // padding_h is zero if U8G2_BTN_PADWIDTH is set
|
||||
{
|
||||
xx = (flags & U8G2_BTN_BW_MASK) - border_width;
|
||||
ww = u8g2_GetDisplayWidth(u8g2);
|
||||
ww -= 2*((flags & U8G2_BTN_BW_MASK) - border_width);
|
||||
//printf("xx=%d ww=%d\n", xx, ww);
|
||||
//printf("clip_x1=%d clip_x0=%d\n", u8g2->clip_x1, u8g2->clip_x0);
|
||||
}
|
||||
else
|
||||
{
|
||||
xx = x;
|
||||
xx -= text_x_offset;
|
||||
xx -= padding_h;
|
||||
xx -= border_width;
|
||||
ww = w+2*padding_h+2*border_width;
|
||||
}
|
||||
|
||||
yy = y;
|
||||
yy += u8g2->font_calc_vref(u8g2);
|
||||
yy -= a;
|
||||
yy -= padding_v;
|
||||
yy -= border_width;
|
||||
hh = a-d+2*padding_v+2*border_width;
|
||||
if ( border_width == 0 )
|
||||
break;
|
||||
u8g2_DrawRFrame(u8g2, xx, yy, ww, hh, r);
|
||||
if ( (flags & U8G2_BTN_BW_MASK) > 1 )
|
||||
u8g2_DrawRFrame(u8g2, xx, yy, ww, hh, r+1);
|
||||
|
||||
border_width--;
|
||||
if ( r > 1 )
|
||||
r--;
|
||||
}
|
||||
if ( flags & U8G2_BTN_INV )
|
||||
{
|
||||
u8g2_DrawRBox(u8g2, xx, yy, ww, hh,r);
|
||||
u8g2_SetDrawColor(u8g2, 1-u8g2->draw_color);
|
||||
}
|
||||
u8g2_DrawUTF8(u8g2, x,y, text);
|
||||
u8g2_SetDrawColor(u8g2, color_backup);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -234,6 +234,39 @@ uint8_t *u8g2_m_12_12_f(uint8_t *page_cnt)
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_10_16_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 1;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[80];
|
||||
*page_cnt = 1;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_10_16_2(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 2;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[160];
|
||||
*page_cnt = 2;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_10_16_f(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 16;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[1280];
|
||||
*page_cnt = 16;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_16_16_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
@@ -333,6 +366,39 @@ uint8_t *u8g2_m_32_8_f(uint8_t *page_cnt)
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_13_8_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 1;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[104];
|
||||
*page_cnt = 1;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_13_8_2(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 2;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[208];
|
||||
*page_cnt = 2;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_13_8_f(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 8;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[832];
|
||||
*page_cnt = 8;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_8_6_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
@@ -630,39 +696,6 @@ uint8_t *u8g2_m_18_21_f(uint8_t *page_cnt)
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_13_8_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 1;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[104];
|
||||
*page_cnt = 1;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_13_8_2(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 2;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[208];
|
||||
*page_cnt = 2;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_13_8_f(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 8;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[832];
|
||||
*page_cnt = 8;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_11_6_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
@@ -894,6 +927,39 @@ uint8_t *u8g2_m_20_16_f(uint8_t *page_cnt)
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_24_12_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 1;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[192];
|
||||
*page_cnt = 1;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_24_12_2(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 2;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[384];
|
||||
*page_cnt = 2;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_24_12_f(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 12;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[2304];
|
||||
*page_cnt = 12;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_20_13_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
@@ -960,6 +1026,39 @@ uint8_t *u8g2_m_30_20_f(uint8_t *page_cnt)
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_32_16_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 1;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[256];
|
||||
*page_cnt = 1;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_32_16_2(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 2;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[512];
|
||||
*page_cnt = 2;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_32_16_f(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 16;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[4096];
|
||||
*page_cnt = 16;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_40_30_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
@@ -993,6 +1092,39 @@ uint8_t *u8g2_m_40_30_f(uint8_t *page_cnt)
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_20_8_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 1;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[160];
|
||||
*page_cnt = 1;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_20_8_2(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 2;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[320];
|
||||
*page_cnt = 2;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_20_8_f(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 8;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[1280];
|
||||
*page_cnt = 8;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_17_4_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
@@ -1092,36 +1224,36 @@ uint8_t *u8g2_m_48_17_f(uint8_t *page_cnt)
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_32_16_1(uint8_t *page_cnt)
|
||||
uint8_t *u8g2_m_20_12_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 1;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[256];
|
||||
static uint8_t buf[160];
|
||||
*page_cnt = 1;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_32_16_2(uint8_t *page_cnt)
|
||||
uint8_t *u8g2_m_20_12_2(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 2;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[512];
|
||||
static uint8_t buf[320];
|
||||
*page_cnt = 2;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_32_16_f(uint8_t *page_cnt)
|
||||
uint8_t *u8g2_m_20_12_f(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 16;
|
||||
*page_cnt = 12;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[4096];
|
||||
*page_cnt = 16;
|
||||
static uint8_t buf[1920];
|
||||
*page_cnt = 12;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
@@ -1191,36 +1323,36 @@ uint8_t *u8g2_m_22_13_f(uint8_t *page_cnt)
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_24_12_1(uint8_t *page_cnt)
|
||||
uint8_t *u8g2_m_19_4_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 1;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[192];
|
||||
static uint8_t buf[152];
|
||||
*page_cnt = 1;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_24_12_2(uint8_t *page_cnt)
|
||||
uint8_t *u8g2_m_19_4_2(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 2;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[384];
|
||||
static uint8_t buf[304];
|
||||
*page_cnt = 2;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_24_12_f(uint8_t *page_cnt)
|
||||
uint8_t *u8g2_m_19_4_f(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 12;
|
||||
*page_cnt = 4;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[2304];
|
||||
*page_cnt = 12;
|
||||
static uint8_t buf[608];
|
||||
*page_cnt = 4;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
@@ -1257,6 +1389,72 @@ uint8_t *u8g2_m_20_10_f(uint8_t *page_cnt)
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_20_4_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 1;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[160];
|
||||
*page_cnt = 1;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_20_4_2(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 2;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[320];
|
||||
*page_cnt = 2;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_20_4_f(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 4;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[640];
|
||||
*page_cnt = 4;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_20_17_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 1;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[160];
|
||||
*page_cnt = 1;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_20_17_2(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 2;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[320];
|
||||
*page_cnt = 2;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_20_17_f(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
*page_cnt = 17;
|
||||
return 0;
|
||||
#else
|
||||
static uint8_t buf[2720];
|
||||
*page_cnt = 17;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
uint8_t *u8g2_m_22_9_1(uint8_t *page_cnt)
|
||||
{
|
||||
#ifdef U8G2_USE_DYNAMIC_ALLOC
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -524,7 +524,7 @@ int8_t u8g2_font_decode_glyph(u8g2_t *u8g2, const uint8_t *glyph_data)
|
||||
int8_t h;
|
||||
u8g2_font_decode_t *decode = &(u8g2->font_decode);
|
||||
|
||||
u8g2_font_setup_decode(u8g2, glyph_data);
|
||||
u8g2_font_setup_decode(u8g2, glyph_data); /* set values in u8g2->font_decode data structure */
|
||||
h = u8g2->font_decode.glyph_height;
|
||||
|
||||
x = u8g2_font_decode_get_signed_bits(decode, u8g2->font_info.bits_per_char_x);
|
||||
@@ -1118,6 +1118,9 @@ static u8g2_uint_t u8g2_string_width(u8g2_t *u8g2, const char *str)
|
||||
{
|
||||
uint16_t e;
|
||||
u8g2_uint_t w, dx;
|
||||
#ifdef U8G2_BALANCED_STR_WIDTH_CALCULATION
|
||||
int8_t initial_x_offset = -64;
|
||||
#endif
|
||||
|
||||
u8g2->font_decode.glyph_width = 0;
|
||||
u8x8_utf8_init(u8g2_GetU8x8(u8g2));
|
||||
@@ -1137,17 +1140,29 @@ static u8g2_uint_t u8g2_string_width(u8g2_t *u8g2, const char *str)
|
||||
if ( e != 0x0fffe )
|
||||
{
|
||||
dx = u8g2_GetGlyphWidth(u8g2, e); /* delta x value of the glyph */
|
||||
#ifdef U8G2_BALANCED_STR_WIDTH_CALCULATION
|
||||
if ( initial_x_offset == -64 )
|
||||
initial_x_offset = u8g2->glyph_x_offset;
|
||||
#endif
|
||||
//printf("'%c' x=%d dx=%d w=%d io=%d ", e, u8g2->glyph_x_offset, dx, u8g2->font_decode.glyph_width, initial_x_offset);
|
||||
w += dx;
|
||||
}
|
||||
}
|
||||
//printf("\n");
|
||||
|
||||
/* adjust the last glyph, check for issue #16: do not adjust if width is 0 */
|
||||
if ( u8g2->font_decode.glyph_width != 0 )
|
||||
{
|
||||
//printf("string width adjust dx=%d glyph_width=%d x-offset=%d\n", dx, u8g2->font_decode.glyph_width, u8g2->glyph_x_offset);
|
||||
w -= dx;
|
||||
w += u8g2->font_decode.glyph_width; /* the real pixel width of the glyph, sideeffect of GetGlyphWidth */
|
||||
/* issue #46: we have to add the x offset also */
|
||||
w += u8g2->glyph_x_offset; /* this value is set as a side effect of u8g2_GetGlyphWidth() */
|
||||
#ifdef U8G2_BALANCED_STR_WIDTH_CALCULATION
|
||||
/* https://github.com/olikraus/u8g2/issues/1561 */
|
||||
if ( initial_x_offset > 0 )
|
||||
w+=initial_x_offset;
|
||||
#endif
|
||||
}
|
||||
// printf("w=%d \n", w);
|
||||
|
||||
@@ -1171,18 +1186,31 @@ static void u8g2_GetGlyphHorizontalProperties(u8g2_t *u8g2, uint16_t requested_e
|
||||
int8_t u8g2_GetStrX(u8g2_t *u8g2, const char *s)
|
||||
{
|
||||
uint8_t w;
|
||||
int8_t ox, dx;
|
||||
int8_t dx;
|
||||
int8_t ox = 0;
|
||||
u8g2_GetGlyphHorizontalProperties(u8g2, *s, &w, &ox, &dx);
|
||||
return ox;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Warning: This function needs to be fixed. I think it was taken over from u8glib, but not fixed as of now
|
||||
The main difference for this procedure compared to the normal get width, should be, that the initial
|
||||
offset is removed
|
||||
|
||||
Idea: for the user interface it probably would be better to add the xoffset of the first char to the end, so that the overall word looks better.
|
||||
Maybe then the procedure should be called differently, maybe balanced width instead of exact width
|
||||
|
||||
u8g2_calculate_exact_string_width is now OBSOLETE, instead the above str width calculation has been updated:
|
||||
https://github.com/olikraus/u8g2/issues/1561
|
||||
*/
|
||||
#ifdef OBSOLETE
|
||||
static u8g2_uint_t u8g2_calculate_exact_string_width(u8g2_t *u8g2, const char *str)
|
||||
{
|
||||
|
||||
u8g2_uint_t w;
|
||||
const char *s = str;
|
||||
uint16_t enc;
|
||||
u8g2_uint_t w;
|
||||
uint8_t cnt;
|
||||
uint8_t gw;
|
||||
int8_t ox, dx;
|
||||
|
||||
@@ -1191,18 +1219,32 @@ static u8g2_uint_t u8g2_calculate_exact_string_width(u8g2_t *u8g2, const char *s
|
||||
|
||||
|
||||
/* check for empty string, width is already 0 */
|
||||
do
|
||||
cnt = 0;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
enc = u8g2->u8x8.next_cb(u8g2_GetU8x8(u8g2), (uint8_t)*str);
|
||||
str++;
|
||||
} while( enc == 0x0fffe );
|
||||
enc = u8g2->u8x8.next_cb(u8g2_GetU8x8(u8g2), (uint8_t)*s);
|
||||
if ( enc == 0x0ffff )
|
||||
break;
|
||||
s++;
|
||||
if ( enc != 0x0fffe )
|
||||
{
|
||||
if ( cnt == 0 )
|
||||
{
|
||||
/* get glyph properties of the first char */
|
||||
u8g2_GetGlyphHorizontalProperties(u8g2, enc, &gw, &ox, &dx);
|
||||
}
|
||||
cnt++;
|
||||
if ( cnt > 2 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( enc== 0x0ffff )
|
||||
return w;
|
||||
|
||||
/* get the glyph information of the first char. This must be valid, because we already checked for the empty string */
|
||||
/* if *s is not inside the font, then the cached parameters of the glyph are all zero */
|
||||
u8g2_GetGlyphHorizontalProperties(u8g2, enc, &gw, &ox, &dx);
|
||||
if ( cnt == 0 )
|
||||
return 0;
|
||||
|
||||
if ( cnt == 1 )
|
||||
return gw;
|
||||
|
||||
/* strlen(s) == 1: width = width(s[0]) */
|
||||
/* strlen(s) == 2: width = - offx(s[0]) + deltax(s[0]) + offx(s[1]) + width(s[1]) */
|
||||
@@ -1213,39 +1255,37 @@ static u8g2_uint_t u8g2_calculate_exact_string_width(u8g2_t *u8g2, const char *s
|
||||
w = -ox;
|
||||
for(;;)
|
||||
{
|
||||
|
||||
/* check and stop if the end of the string is reached */
|
||||
do
|
||||
{
|
||||
enc = u8g2->u8x8.next_cb(u8g2_GetU8x8(u8g2), (uint8_t)*str);
|
||||
str++;
|
||||
} while( enc == 0x0fffe );
|
||||
enc = u8g2->u8x8.next_cb(u8g2_GetU8x8(u8g2), (uint8_t)*str);
|
||||
if ( enc== 0x0ffff )
|
||||
break;
|
||||
|
||||
u8g2_GetGlyphHorizontalProperties(u8g2, enc, &gw, &ox, &dx);
|
||||
|
||||
/* if there are still more characters, add the delta to the next glyph */
|
||||
w += dx;
|
||||
str++;
|
||||
if ( enc != 0x0fffe )
|
||||
{
|
||||
u8g2_GetGlyphHorizontalProperties(u8g2, enc, &gw, &ox, &dx);
|
||||
/* if there are still more characters, add the delta to the next glyph */
|
||||
w += dx;
|
||||
}
|
||||
}
|
||||
|
||||
/* finally calculate the width of the last char */
|
||||
/* here is another exception, if the last char is a black, use the dx value instead */
|
||||
if ( enc != ' ' )
|
||||
/* here is another exception, if the last char is a blank, use the dx value instead */
|
||||
if ( gw != 0 )
|
||||
{
|
||||
w -= dx; /* remove the last dx */
|
||||
/* if g was not updated in the for loop (strlen() == 1), then the initial offset x gets removed */
|
||||
w += gw;
|
||||
w += ox;
|
||||
}
|
||||
else
|
||||
{
|
||||
w += dx;
|
||||
//w += dx;
|
||||
}
|
||||
|
||||
|
||||
return w;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1257,11 +1297,13 @@ u8g2_uint_t u8g2_GetStrWidth(u8g2_t *u8g2, const char *s)
|
||||
return u8g2_string_width(u8g2, s);
|
||||
}
|
||||
|
||||
/* OBSOLETE
|
||||
u8g2_uint_t u8g2_GetExactStrWidth(u8g2_t *u8g2, const char *s)
|
||||
{
|
||||
u8g2->u8x8.next_cb = u8x8_ascii_next;
|
||||
return u8g2_calculate_exact_string_width(u8g2, s);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
source: https://en.wikipedia.org/wiki/UTF-8
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -150,17 +150,17 @@ u8g2_uint_t u8g2_DrawUTF8Lines(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_
|
||||
static u8g2_uint_t u8g2_draw_selection_list_line(u8g2_t *u8g2, u8sl_t *u8sl, u8g2_uint_t y, uint8_t idx, const char *s) U8G2_NOINLINE;
|
||||
static u8g2_uint_t u8g2_draw_selection_list_line(u8g2_t *u8g2, u8sl_t *u8sl, u8g2_uint_t y, uint8_t idx, const char *s)
|
||||
{
|
||||
u8g2_uint_t yy;
|
||||
//u8g2_uint_t yy;
|
||||
uint8_t border_size = 0;
|
||||
uint8_t is_invert = 0;
|
||||
|
||||
u8g2_uint_t line_height = u8g2_GetAscent(u8g2) - u8g2_GetDescent(u8g2)+MY_BORDER_SIZE;
|
||||
|
||||
/* calculate offset from display upper border */
|
||||
yy = idx;
|
||||
yy -= u8sl->first_pos;
|
||||
yy *= line_height;
|
||||
yy += y;
|
||||
//yy = idx;
|
||||
//yy -= u8sl->first_pos;
|
||||
//yy *= line_height;
|
||||
//yy += y;
|
||||
|
||||
/* check whether this is the current cursor line */
|
||||
if ( idx == u8sl->current_pos )
|
||||
|
||||
@@ -328,6 +328,22 @@ void u8g2_draw_l90_mirrorr_r0(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_u
|
||||
u8g2_draw_hv_line_2dir(u8g2, xx, y, len, dir);
|
||||
}
|
||||
|
||||
void u8g2_draw_mirror_vertical_r0(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
||||
{
|
||||
u8g2_uint_t yy;
|
||||
yy = u8g2->height;
|
||||
yy -= y;
|
||||
if ( (dir & 1) == 1 )
|
||||
{
|
||||
yy -= len;
|
||||
}
|
||||
else
|
||||
{
|
||||
yy--;
|
||||
}
|
||||
u8g2_draw_hv_line_2dir(u8g2, x, yy, len, dir);
|
||||
}
|
||||
|
||||
/* dir = 0 or 1 */
|
||||
void u8g2_draw_l90_r1(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
||||
{
|
||||
@@ -434,6 +450,7 @@ const u8g2_cb_t u8g2_cb_r2 = { u8g2_update_dimension_r2, u8g2_update_page_win_r2
|
||||
const u8g2_cb_t u8g2_cb_r3 = { u8g2_update_dimension_r3, u8g2_update_page_win_r3, u8g2_draw_l90_r3 };
|
||||
|
||||
const u8g2_cb_t u8g2_cb_mirror = { u8g2_update_dimension_r0, u8g2_update_page_win_r0, u8g2_draw_l90_mirrorr_r0 };
|
||||
const u8g2_cb_t u8g2_cb_mirror_vertical = { u8g2_update_dimension_r0, u8g2_update_page_win_r0, u8g2_draw_mirror_vertical_r0 };
|
||||
|
||||
/*============================================*/
|
||||
/* setup for the null device */
|
||||
|
||||
@@ -89,7 +89,9 @@
|
||||
/* Global Defines */
|
||||
|
||||
/* Undefine this to remove u8x8_SetContrast function */
|
||||
#ifndef U8X8_WITHOUT_SET_CONTRAST
|
||||
#define U8X8_WITH_SET_CONTRAST
|
||||
#endif
|
||||
|
||||
/* Define this for an additional user pointer inside the u8x8 data struct */
|
||||
//#define U8X8_WITH_USER_PTR
|
||||
@@ -188,6 +190,20 @@ uint8_t u8x8_pgm_read_esp(const uint8_t * addr); /* u8x8_8x8.c */
|
||||
#define U8X8_USE_PINS
|
||||
#endif
|
||||
|
||||
#ifdef __RTTHREAD__
|
||||
#define U8X8_USE_PINS
|
||||
#endif
|
||||
|
||||
#ifdef __LUATOS__
|
||||
#define U8X8_USE_PINS
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_LINUX__) || defined(unix) || defined(__unix__) || defined(__unix)
|
||||
/* https://github.com/olikraus/u8g2/pull/1666 */
|
||||
#define U8X8_USE_PINS
|
||||
#define U8X8_WITH_USER_PTR
|
||||
#endif
|
||||
|
||||
/*==========================================*/
|
||||
/* U8X8 typedefs and data structures */
|
||||
|
||||
@@ -544,6 +560,14 @@ uint8_t u8x8_DrawTile(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t cnt, uint8_t *
|
||||
*/
|
||||
void u8x8_SetupMemory(u8x8_t *u8x8);
|
||||
|
||||
/*
|
||||
Init the interface to the display, but not the display itself.
|
||||
This might be useful, if the display is already running.
|
||||
|
||||
InitInterface is called from InitDisplay, do not call both functions.
|
||||
*/
|
||||
void u8x8_InitInterface(u8x8_t *u8x8);
|
||||
|
||||
/*
|
||||
After calling u8x8_SetupMemory()/u8x8_Setup(), init the display hardware itself.
|
||||
This will will the first time, u8x8 talks to the display.
|
||||
@@ -632,6 +656,7 @@ void u8x8_SendF(u8x8_t * u8x8, const char *fmt, ...);
|
||||
void u8x8_cad_SendSequence(u8x8_t *u8x8, uint8_t const *data);
|
||||
uint8_t u8x8_cad_empty(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_cad_110(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_gu800_cad_110(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_cad_001(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_cad_011(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_cad_100(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
@@ -640,7 +665,8 @@ uint8_t u8x8_cad_ssd13xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *a
|
||||
uint8_t u8x8_cad_ssd13xx_fast_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_cad_st75256_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_cad_ld7032_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_cad_uc16xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_cad_uc16xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); /* CAD=001 */
|
||||
uint8_t u8x8_cad_uc1638_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); /* CAD=011 */
|
||||
|
||||
|
||||
/*==========================================*/
|
||||
@@ -805,6 +831,7 @@ uint8_t u8x8_d_uc1701_mini12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void
|
||||
uint8_t u8x8_d_ssd1305_128x32_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1305_128x32_adafruit(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1305_128x64_adafruit(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1305_128x64_raystar(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1306_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1306_128x64_vcomh0(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1306_128x64_alt0(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
@@ -813,20 +840,24 @@ uint8_t u8x8_d_ssd1309_128x64_noname2(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int
|
||||
uint8_t u8x8_d_sh1106_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_sh1106_128x64_vcomh0(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_sh1106_128x64_winstar(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_sh1106_128x32_visionox(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); // located in ssd1306_128x32
|
||||
uint8_t u8x8_d_sh1106_72x40_wise(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_sh1106_64x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_sh1107_64x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_sh1107_seeed_96x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_sh1107_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_sh1107_128x80(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_sh1107_pimoroni_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_sh1107_seeed_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_sh1108_160x160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_sh1122_256x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7920_256x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7920_192x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7920_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1306_2040x16(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1306_128x32_univision(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1306_128x32_winstar(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1306_102x64_ea_oleds102(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); /* u8x8_ssd1309.c */
|
||||
uint8_t u8x8_d_ssd1306_64x48_er(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1306_48x64_winstar(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1306_64x32_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
@@ -835,9 +866,11 @@ uint8_t u8x8_d_ssd1306_96x16_er(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void
|
||||
uint8_t u8x8_d_ssd1306_72x40_er(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ls013b7dh03_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ls027b7dh01_400x240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ls027b7dh01_m0_400x240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ls013b7dh05_144x168(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7511_avd_320x240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7528_nhd_c160100(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7528_erc16064(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7565_ea_dogm128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7565_lm6063(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7565_64128n(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
@@ -853,14 +886,19 @@ uint8_t u8x8_d_st7565_erc12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void
|
||||
uint8_t u8x8_d_st7565_erc12864_alt(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); /* issue #790 */
|
||||
uint8_t u8x8_d_st7567_pi_132x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7567_jlx12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7567_122x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7567_enh_dg128064(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7567_enh_dg128064i(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7567_64x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7567_hem6432(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7567_os12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7571_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7571_128x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7586s_s028hn118a(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7586s_erc240160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7586s_ymc240160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7588_jlx12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st75160_jm16096(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st75256_jlx256128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st75256_wo256x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st75256_jlx256160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
@@ -873,6 +911,7 @@ uint8_t u8x8_d_st75256_jlx19296(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void
|
||||
uint8_t u8x8_d_st75320_jlx320240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); /* https://github.com/olikraus/u8g2/issues/921 */
|
||||
uint8_t u8x8_d_nt7534_tg12864r(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); /* u8x8_d_st7565.c */
|
||||
uint8_t u8x8_d_ld7032_60x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ld7032_60x32_alt(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_t6963_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_t6963_240x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_t6963_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
@@ -883,6 +922,8 @@ uint8_t u8x8_d_ssd1316_128x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
|
||||
uint8_t u8x8_d_ssd1317_96x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1318_128x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1318_128x96_xcp(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1320_160x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1320_160x132(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1322_nhd_256x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1322_nhd_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_a2printer_384x240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
@@ -899,21 +940,28 @@ uint8_t u8x8_d_ssd1327_ws_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, vo
|
||||
uint8_t u8x8_d_ssd1327_visionox_128x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1326_er_256x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1329_128x96_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1329_96x96_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_uc1601_128x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_uc1601_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_uc1604_jlx19264(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_uc1608_erc24064(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_uc1608_dem240064(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_uc1608_erc240120(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_uc1608_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_uc1609_slg19264(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_uc1610_ea_dogxl160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_uc1611_ea_dogm240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_uc1611_ea_dogxl240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_uc1611_ew50850(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); /* 240x160 */
|
||||
uint8_t u8x8_d_uc1611_cg160160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); /* 160x160 */
|
||||
uint8_t u8x8_d_uc1617_jlx128128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_uc1611_ids4073(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); /* 256x128 */
|
||||
uint8_t u8x8_d_uc1638_160x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_uc1638_192x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ks0108_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ks0108_erm19264(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_t7932_150x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); /* t7932 and hd44102 are compatible */
|
||||
uint8_t u8x8_d_hd44102_100x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); /* t7932 and hd44102 are compatible */
|
||||
uint8_t u8x8_d_sbn1661_122x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_sed1520_122x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_pcd8544_84x48(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
@@ -936,6 +984,9 @@ uint8_t u8x8_d_max7219_64x8(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *ar
|
||||
uint8_t u8x8_d_max7219_32x8(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_max7219_16x16(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_max7219_8x8(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_s1d15e06_160100(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_s1d15721_240x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_gu800_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -248,6 +248,52 @@ uint8_t u8x8_cad_110(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
convert to bytes by using
|
||||
dc = 1 for commands and args and
|
||||
dc = 0 for data
|
||||
*/
|
||||
uint8_t u8x8_gu800_cad_110(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t *data;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_CAD_SEND_CMD:
|
||||
u8x8_byte_SetDC(u8x8, 1);
|
||||
u8x8_byte_StartTransfer(u8x8);
|
||||
u8x8_byte_SendByte(u8x8, arg_int);
|
||||
u8x8_byte_EndTransfer(u8x8);
|
||||
break;
|
||||
case U8X8_MSG_CAD_SEND_ARG:
|
||||
u8x8_byte_SetDC(u8x8, 1);
|
||||
u8x8_byte_StartTransfer(u8x8);
|
||||
u8x8_byte_SendByte(u8x8, arg_int);
|
||||
u8x8_byte_EndTransfer(u8x8);
|
||||
break;
|
||||
case U8X8_MSG_CAD_SEND_DATA:
|
||||
u8x8_byte_SetDC(u8x8, 0);
|
||||
data = (uint8_t *)arg_ptr;
|
||||
while( arg_int > 0 )
|
||||
{
|
||||
u8x8_byte_StartTransfer(u8x8);
|
||||
u8x8_byte_SendByte(u8x8, *data);
|
||||
u8x8_byte_EndTransfer(u8x8);
|
||||
data++;
|
||||
arg_int--;
|
||||
}
|
||||
break;
|
||||
case U8X8_MSG_CAD_INIT:
|
||||
u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
||||
break;
|
||||
case U8X8_MSG_CAD_START_TRANSFER:
|
||||
case U8X8_MSG_CAD_END_TRANSFER:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
convert to bytes by using
|
||||
dc = 1 for commands and args and
|
||||
@@ -666,7 +712,7 @@ uint8_t u8x8_cad_ld7032_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *ar
|
||||
|
||||
/* cad procedure for the UC16xx family in I2C mode */
|
||||
/* u8x8_byte_SetDC is not used */
|
||||
/* DC bit is encoded into the adr byte */
|
||||
/* DC bit is encoded into the adr byte, structure is CAD001 */
|
||||
uint8_t u8x8_cad_uc16xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
static uint8_t in_transfer = 0;
|
||||
@@ -695,6 +741,7 @@ uint8_t u8x8_cad_uc16xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *ar
|
||||
}
|
||||
u8x8_byte_SendByte(u8x8, arg_int);
|
||||
in_transfer = 1;
|
||||
// is_data = 0; // 20 Jun 2021: I assume that this is missing here
|
||||
break;
|
||||
case U8X8_MSG_CAD_SEND_DATA:
|
||||
if ( in_transfer != 0 )
|
||||
@@ -715,6 +762,7 @@ uint8_t u8x8_cad_uc16xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *ar
|
||||
u8x8_byte_StartTransfer(u8x8);
|
||||
}
|
||||
in_transfer = 1;
|
||||
// is_data = 1; // 20 Jun 2021: I assume that this is missing here
|
||||
|
||||
p = arg_ptr;
|
||||
while( arg_int > 24 )
|
||||
@@ -747,3 +795,110 @@ uint8_t u8x8_cad_uc16xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *ar
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* cad procedure for the UC1638 in I2C mode */
|
||||
/* same as u8x8_cad_uc16xx_i2c but CAD structure is CAD011 */
|
||||
uint8_t u8x8_cad_uc1638_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
static uint8_t in_transfer = 0;
|
||||
static uint8_t is_data = 0;
|
||||
uint8_t *p;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_CAD_SEND_CMD:
|
||||
if ( in_transfer != 0 )
|
||||
{
|
||||
if ( is_data != 0 )
|
||||
{
|
||||
/* transfer mode is active, but data transfer */
|
||||
u8x8_byte_EndTransfer(u8x8);
|
||||
/* clear the lowest two bits of the adr */
|
||||
u8x8_SetI2CAddress( u8x8, u8x8_GetI2CAddress(u8x8)&0x0fc );
|
||||
u8x8_byte_StartTransfer(u8x8);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* clear the lowest two bits of the adr */
|
||||
u8x8_SetI2CAddress( u8x8, u8x8_GetI2CAddress(u8x8)&0x0fc );
|
||||
u8x8_byte_StartTransfer(u8x8);
|
||||
}
|
||||
u8x8_byte_SendByte(u8x8, arg_int);
|
||||
in_transfer = 1;
|
||||
is_data = 0;
|
||||
break;
|
||||
case U8X8_MSG_CAD_SEND_ARG:
|
||||
if ( in_transfer != 0 )
|
||||
{
|
||||
if ( is_data == 0 )
|
||||
{
|
||||
/* transfer mode is active, but data transfer */
|
||||
u8x8_byte_EndTransfer(u8x8);
|
||||
/* clear the lowest two bits of the adr */
|
||||
u8x8_SetI2CAddress( u8x8, (u8x8_GetI2CAddress(u8x8)&0x0fc)|2 );
|
||||
u8x8_byte_StartTransfer(u8x8);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* clear the lowest two bits of the adr */
|
||||
u8x8_SetI2CAddress( u8x8, (u8x8_GetI2CAddress(u8x8)&0x0fc)|2 );
|
||||
u8x8_byte_StartTransfer(u8x8);
|
||||
}
|
||||
u8x8_byte_SendByte(u8x8, arg_int);
|
||||
in_transfer = 1;
|
||||
is_data = 1;
|
||||
break;
|
||||
case U8X8_MSG_CAD_SEND_DATA:
|
||||
if ( in_transfer != 0 )
|
||||
{
|
||||
if ( is_data == 0 )
|
||||
{
|
||||
/* transfer mode is active, but data transfer */
|
||||
u8x8_byte_EndTransfer(u8x8);
|
||||
/* clear the lowest two bits of the adr */
|
||||
u8x8_SetI2CAddress( u8x8, (u8x8_GetI2CAddress(u8x8)&0x0fc)|2 );
|
||||
u8x8_byte_StartTransfer(u8x8);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* clear the lowest two bits of the adr */
|
||||
u8x8_SetI2CAddress( u8x8, (u8x8_GetI2CAddress(u8x8)&0x0fc)|2 );
|
||||
u8x8_byte_StartTransfer(u8x8);
|
||||
}
|
||||
in_transfer = 1;
|
||||
is_data = 1;
|
||||
|
||||
p = arg_ptr;
|
||||
while( arg_int > 24 )
|
||||
{
|
||||
u8x8->byte_cb(u8x8, U8X8_MSG_CAD_SEND_DATA, 24, p);
|
||||
arg_int-=24;
|
||||
p+=24;
|
||||
u8x8_byte_EndTransfer(u8x8);
|
||||
u8x8_byte_StartTransfer(u8x8);
|
||||
}
|
||||
u8x8->byte_cb(u8x8, U8X8_MSG_CAD_SEND_DATA, arg_int, p);
|
||||
|
||||
break;
|
||||
case U8X8_MSG_CAD_INIT:
|
||||
/* apply default i2c adr if required so that the start transfer msg can use this */
|
||||
if ( u8x8->i2c_address == 255 )
|
||||
u8x8->i2c_address = 0x078; /* see also https://github.com/olikraus/u8g2/issues/371 for a discussion on this value */
|
||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
||||
case U8X8_MSG_CAD_START_TRANSFER:
|
||||
in_transfer = 0;
|
||||
/* actual start is delayed, because we do not whether this is data or cmd transfer */
|
||||
break;
|
||||
case U8X8_MSG_CAD_END_TRANSFER:
|
||||
if ( in_transfer != 0 )
|
||||
u8x8_byte_EndTransfer(u8x8);
|
||||
in_transfer = 0;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
213
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_gu800.c
Normal file
213
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_gu800.c
Normal file
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
|
||||
u8x8_d_gu800.c
|
||||
|
||||
Support for GU800 series of VFD displays
|
||||
https://www.noritake-elec.com/products/vfd-display-module/dot-matrix-graphic-display/gu-800-series
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2021, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
|
||||
u8x8_gu800_cad_110
|
||||
|
||||
WARNING: DO NOT USE THIS FILE AS TEMPLATE:
|
||||
|
||||
This code requires a special cad callback which includes the start
|
||||
and end transfer code. As a consequence this code does not include any
|
||||
start / end transfer calls.
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_gu800_128x64_powersave0_seq[] = {
|
||||
U8X8_CA(0x024, 0x040), /* Byte 1: Layer 0010xx00, Byte 2: 0x40 (graphics on, normal mode, no or/xor) */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_gu800_128x64_powersave1_seq[] = {
|
||||
U8X8_CA(0x020, 0x040), /* Byte 1: Layer 0010xx00, Byte 2: 0x40 (graphics on, normal mode, no or/xor) */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
/* hardware flip is not supported by GU800 */
|
||||
#ifdef NOT_SUPPORTED
|
||||
static const uint8_t u8x8_d_gu800_128x64_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_gu800_128x64_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
#endif
|
||||
|
||||
uint8_t u8x8_d_gu800_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gu800_128x64_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gu800_128x64_powersave1_seq);
|
||||
break;
|
||||
#ifdef NOT_SUPPORTED
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gu800_128x64_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gu800_128x64_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_SendCmd(u8x8, 0x40 | (arg_int >> 4) ); /* GU800 has range from 0..15 */
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x064 );
|
||||
u8x8_cad_SendArg(u8x8, x );
|
||||
u8x8_cad_SendCmd(u8x8, 0x060 );
|
||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos) );
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
/* SendData can not handle more than 255 bytes, treat c > 31 correctly */
|
||||
if ( c > 31 )
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 248, ptr); /* 31*8=248 */
|
||||
ptr+=248;
|
||||
c -= 31;
|
||||
}
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr);
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const uint8_t u8x8_d_gu800_128x64_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x05f), /* clear all RAM, clear address counters */
|
||||
U8X8_DLY(1), /* delay for 1 ms (see datasheet) */
|
||||
|
||||
/* configure all area as graphics RAM */
|
||||
U8X8_CA(0x62,0), U8X8_D1(0xff),
|
||||
U8X8_CA(0x62,1), U8X8_D1(0xff),
|
||||
U8X8_CA(0x62,2), U8X8_D1(0xff),
|
||||
U8X8_CA(0x62,3), U8X8_D1(0xff),
|
||||
U8X8_CA(0x62,4), U8X8_D1(0xff),
|
||||
U8X8_CA(0x62,5), U8X8_D1(0xff),
|
||||
U8X8_CA(0x62,6), U8X8_D1(0xff),
|
||||
U8X8_CA(0x62,7), U8X8_D1(0xff),
|
||||
|
||||
U8X8_CA(0x70, 0), /* horizontal shift */
|
||||
U8X8_C(0xb0), /* vertical shift */
|
||||
U8X8_C(0x4f), /* max brightness */
|
||||
U8X8_C(0x84), /* x increment */
|
||||
|
||||
// U8X8_CA(0x024, 0x040) /* display on */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_d_gu800_128x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0, /* GU800: CSS signal */
|
||||
/* chip_disable_level = */ 1, /* GU800: CSS signal */
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 40,
|
||||
/* pre_chip_disable_wait_ns = */ 150,
|
||||
/* reset_pulse_width_ms = */ 2, /* GU800: Unspecified in datasheet */
|
||||
/* post_reset_wait_ms = */ 2, /* GU800: Min 1.5ms per datasheet */
|
||||
/* sda_setup_time_ns = */ 40, /* GU800: 40ns according to the timing diagram */
|
||||
/* sck_pulse_width_ns = */ 80, /* GU800: Min 80ns per datasheet */
|
||||
/* sck_clock_hz = */ 4000000UL,
|
||||
/* spi_mode = */ 2, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4, /* GU800: Not used */
|
||||
/* data_setup_time_ns = */ 40, /* GU800: Min 40ns per datasheet */
|
||||
/* write_pulse_width_ns = */ 150, /* GU800: Min 150ns per datasheet */
|
||||
/* tile_width = */ 16, /* width of 16*8=128 pixel */
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_gu800_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_gu800_common(u8x8, msg, arg_int, arg_ptr) )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_d_gu800_128x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gu800_128x64_init_seq);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
352
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_hd44102.c
Normal file
352
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_hd44102.c
Normal file
@@ -0,0 +1,352 @@
|
||||
/*
|
||||
|
||||
u8x8_d_hd44102.c
|
||||
|
||||
Support for HD44102 and T7932 controller (https://github.com/olikraus/u8g2/issues/1492)
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2021, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_hd44102_init_seq[] = {
|
||||
U8X8_C(0x03b), /* upcount */
|
||||
U8X8_C(0x03e), /* start at the top */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_hd44102_powersave0_seq[] = {
|
||||
U8X8_C(0x039), /* display on */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_hd44102_powersave1_seq[] = {
|
||||
U8X8_C(0x038), /* display off */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
/*
|
||||
data: pointer to "cnt" bytes
|
||||
cnt: number of bytes, which should be sent
|
||||
page: 0..3: the current page within the display
|
||||
offset: offset location on the display, where the data should be placed
|
||||
cs_none: 3-bit chip select pattern for not selecting any display
|
||||
cs0: 3-bit chip select pattern for the left display (0..49)
|
||||
cs1: 3-bit chip select pattern for the middle display (50..99)
|
||||
cs2: 3-bit chip select pattern for the right display (100..149)
|
||||
|
||||
The csX bit pattern is:
|
||||
bit 0: CS
|
||||
bit 1: CS1
|
||||
bit 2: CS2
|
||||
see u8x8_byte_set_ks0108_cs() in u8x8_byte.c
|
||||
|
||||
*/
|
||||
static void u8x8_hd44102_outy(u8x8_t *u8x8, uint8_t *data, uint8_t cnt, uint8_t page, uint8_t offset, uint8_t cs_none, uint8_t cs0, uint8_t cs1, uint8_t cs2)
|
||||
{
|
||||
uint8_t pos = offset;
|
||||
uint8_t data_cnt;
|
||||
|
||||
/* write to left display? */
|
||||
if ( pos < 50 && cnt > 0 )
|
||||
{
|
||||
/* calculate number of bytes to sent */
|
||||
data_cnt = 50 - pos;
|
||||
if ( data_cnt > cnt )
|
||||
data_cnt = cnt;
|
||||
if ( data_cnt > 50 )
|
||||
data_cnt = 50;
|
||||
|
||||
/* sent the data */
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, cs0, NULL);
|
||||
u8x8_cad_SendCmd(u8x8, (page << 6) | pos );
|
||||
u8x8_cad_SendData(u8x8, data_cnt, data);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, cs_none, NULL);
|
||||
|
||||
/* adjust the data */
|
||||
data += data_cnt;
|
||||
pos += data_cnt;
|
||||
cnt -= data_cnt;
|
||||
}
|
||||
|
||||
/* write to middle display? */
|
||||
if ( pos < 100 && cnt > 0 )
|
||||
{
|
||||
/* calculate number of bytes to sent */
|
||||
data_cnt = 100 - pos;
|
||||
if ( data_cnt > cnt )
|
||||
data_cnt = cnt;
|
||||
if ( data_cnt > 50 )
|
||||
data_cnt = 50;
|
||||
|
||||
/* sent the data */
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, cs1, NULL);
|
||||
u8x8_cad_SendCmd(u8x8, (page << 6) | (pos-50) );
|
||||
u8x8_cad_SendData(u8x8, data_cnt, data);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, cs_none, NULL);
|
||||
|
||||
/* adjust the data */
|
||||
data += data_cnt;
|
||||
pos += data_cnt;
|
||||
cnt -= data_cnt;
|
||||
}
|
||||
|
||||
/* write to right display? */
|
||||
if ( pos < 150 && cnt > 0 )
|
||||
{
|
||||
/* calculate number of bytes to sent */
|
||||
data_cnt = 150 - pos;
|
||||
if ( data_cnt > cnt )
|
||||
data_cnt = cnt;
|
||||
if ( data_cnt > 50 )
|
||||
data_cnt = 50;
|
||||
|
||||
/* sent the data */
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, cs2, NULL);
|
||||
u8x8_cad_SendCmd(u8x8, (page << 6) | (pos-100) );
|
||||
u8x8_cad_SendData(u8x8, data_cnt, data);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, cs_none, NULL);
|
||||
|
||||
/* adjust the data */
|
||||
data += data_cnt;
|
||||
pos += data_cnt;
|
||||
cnt -= data_cnt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_hd44102_150x32_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0, /* KS0108/HD44102: Not used */
|
||||
/* chip_disable_level = */ 1, /* KS0108/HD44102: Not used */
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 100,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 12,
|
||||
/* sck_pulse_width_ns = */ 75, /* KS0108/HD44102: Not used */
|
||||
/* sck_clock_hz = */ 4000000UL, /* KS0108/HD44102: Not used */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4, /* KS0108/HD44102: Not used */
|
||||
/* data_setup_time_ns = */ 200,
|
||||
/* write_pulse_width_ns = */ 250, /* KS0108/HD44102: actially 450 ns, but additional 200 ns are added by the byte transfer function */
|
||||
/* tile_width = */ 19, /* width of 19*8=152 pixel */
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 150,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
//uint8_t u8x8_d_hd44102_150x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
|
||||
uint8_t u8x8_d_t7932_150x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t cs[4] = {1, 2, 4, 0};
|
||||
uint8_t i;
|
||||
uint8_t x, cnt;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_hd44102_150x32_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, cs[i], NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hd44102_init_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, cs[3], NULL);
|
||||
}
|
||||
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, cs[i], NULL);
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hd44102_powersave0_seq);
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hd44102_powersave1_seq);
|
||||
}
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, cs[3], NULL);
|
||||
}
|
||||
break;
|
||||
// The HD44102 can not mirror the cols and rows, use U8g2 for rotation
|
||||
// case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
// break;
|
||||
// The HD44102 has no internal contrast command
|
||||
// case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
// break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
cnt = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
x*=8;
|
||||
cnt*=8;
|
||||
|
||||
do
|
||||
{
|
||||
u8x8_hd44102_outy(u8x8,
|
||||
((u8x8_tile_t *)arg_ptr)->tile_ptr,
|
||||
cnt,
|
||||
((u8x8_tile_t *)arg_ptr)->y_pos,
|
||||
x,
|
||||
cs[3], cs[0], cs[1], cs[2]);
|
||||
arg_int--;
|
||||
x += cnt;
|
||||
} while (arg_int > 0);
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const u8x8_display_info_t u8x8_hd44102_100x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0, /* KS0108/HD44102: Not used */
|
||||
/* chip_disable_level = */ 1, /* KS0108/HD44102: Not used */
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 100,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 12,
|
||||
/* sck_pulse_width_ns = */ 75, /* KS0108/HD44102: Not used */
|
||||
/* sck_clock_hz = */ 4000000UL, /* KS0108/HD44102: Not used */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4, /* KS0108/HD44102: Not used */
|
||||
/* data_setup_time_ns = */ 200,
|
||||
/* write_pulse_width_ns = */ 250, /* KS0108/HD44102: actially 450 ns, but additional 200 ns are added by the byte transfer function */
|
||||
/* tile_width = */ 13, /* width of 13*8=104 pixel */
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 100,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_hd44102_100x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t x, cnt, page;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_hd44102_100x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
{
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, i, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hd44102_init_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
||||
}
|
||||
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
{
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, i, NULL);
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hd44102_powersave0_seq);
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hd44102_powersave1_seq);
|
||||
}
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
||||
}
|
||||
break;
|
||||
// The HD44102 can not mirror the cols and rows, use U8g2 for rotation
|
||||
// case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
// break;
|
||||
// The HD44102 has no internal contrast command
|
||||
// case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
// break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
cnt = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
page = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
||||
x*=8;
|
||||
cnt*=8;
|
||||
if ( page < 4 )
|
||||
{
|
||||
do
|
||||
{
|
||||
u8x8_hd44102_outy(u8x8,
|
||||
((u8x8_tile_t *)arg_ptr)->tile_ptr,
|
||||
cnt,
|
||||
page,
|
||||
x,
|
||||
7, 0, 1, 7);
|
||||
arg_int--;
|
||||
x += cnt;
|
||||
} while (arg_int > 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
u8x8_hd44102_outy(u8x8,
|
||||
((u8x8_tile_t *)arg_ptr)->tile_ptr,
|
||||
cnt,
|
||||
page-4,
|
||||
x,
|
||||
7, 2, 3, 7);
|
||||
arg_int--;
|
||||
x += cnt;
|
||||
} while (arg_int > 0);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
552
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_il3820_296x128.c
Normal file
552
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_il3820_296x128.c
Normal file
@@ -0,0 +1,552 @@
|
||||
/*
|
||||
|
||||
u8x8_d_il3820_296x128.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2017, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
il3820: 200x300x1
|
||||
|
||||
command
|
||||
0x22: assign actions
|
||||
0x20: execute actions
|
||||
|
||||
action for command 0x022 are (more or less guessed)
|
||||
bit 7: Enable Clock
|
||||
bit 6: Enable Charge Pump
|
||||
bit 5: Load Temparture Value (???)
|
||||
bit 4: Load LUT (???)
|
||||
bit 3: Initial Display (???)
|
||||
bit 2: Pattern Display --> Requires about 945ms with the LUT from below
|
||||
bit 1: Disable Charge Pump
|
||||
bit 0: Disable Clock
|
||||
|
||||
Disable Charge Pump and Clock require about 10ms
|
||||
Enable Charge Pump and Clock require about 100 to 300ms
|
||||
|
||||
Notes:
|
||||
- Introduced a refresh display message, which copies RAM to display
|
||||
- Charge pump is always enabled. Charge pump can be enabled/disabled via power save message
|
||||
- U8x8 will not really work because of the two buffers in the SSD1606, however U8g2 should be ok.
|
||||
|
||||
LUT for the 296x128 device (IL3820)
|
||||
LUT (cmd: 0x032 has 30 bytes)
|
||||
section 6.8 of the datasheet mentions 256 bits = 32 bytes for the LUT
|
||||
chapter 7 tells 30 bytes
|
||||
|
||||
according to section 6.8:
|
||||
20 bytes waveform
|
||||
10 bytes timing
|
||||
1 byte named as VSH/VSL
|
||||
1 empty byte
|
||||
according to the command table, the lut has 240 bits (=30 bytes * 8 bits)
|
||||
|
||||
|
||||
LUT / Refresh time
|
||||
total_refresh_time = (refresh_lines + dummy_lines*2)*TGate*TS_Sum/f_OSC
|
||||
|
||||
f_OSC=1MHz (according to the datasheets)
|
||||
refreh_lines = 296 (for the waveshare display, 0x045 cmd)
|
||||
dummy_lines = 22 (for the upcoming u8g2 code, 0x03a cmd)
|
||||
TGate = 62 (POR default, 0x03b cmd)
|
||||
TS_Sum: Sum of all TS entries of the second part of the LUT
|
||||
f_OSC: 1MHz according to the datasheet.
|
||||
|
||||
so we have
|
||||
|
||||
total_refresh_time = 21080*TS_Sum/1000000 = 21ms * TS_Sum
|
||||
|
||||
|
||||
This file includes two devices:
|
||||
u8x8_d_il3820_296x128 --> includes LUT which is probably from the WaveShare 2.9 Vendor
|
||||
u8x8_d_il3820_v2_296x128 --> includes LUT which was optimized for faster speed and lesser flicker
|
||||
|
||||
*/
|
||||
|
||||
/* Waveform part of the LUT (20 bytes) */
|
||||
/* bit 7/6: 1 - 1 transition */
|
||||
/* bit 5/4: 1 - 0 transition */
|
||||
/* bit 3/2: 0 - 1 transition */
|
||||
/* bit 1/0: 0 - 0 transition */
|
||||
/* 00 – VSS */
|
||||
/* 01 – VSH */
|
||||
/* 10 – VSL */
|
||||
/* 11 – NA */
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
/*=================================================*/
|
||||
/* common code for all devices */
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_il3820_296x128_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x22, 0xc0), /* enable clock and charge pump */
|
||||
U8X8_C(0x20), /* execute sequence */
|
||||
U8X8_DLY(200), /* according to my measures it may take up to 150ms */
|
||||
U8X8_DLY(100), /* but it might take longer */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_il3820_296x128_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
/* disable clock and charge pump only, deep sleep is not entered, because we will loose RAM content */
|
||||
U8X8_CA(0x22, 0x02), /* only disable charge pump, HW reset seems to be required if the clock is disabled */
|
||||
U8X8_C(0x20), /* execute sequence */
|
||||
U8X8_DLY(20),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
// static const uint8_t u8x8_d_il3820_296x128_flip0_seq[] = {
|
||||
// U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
// U8X8_END_TRANSFER(), /* disable chip */
|
||||
// U8X8_END() /* end of sequence */
|
||||
// };
|
||||
|
||||
// static const uint8_t u8x8_d_il3820_296x128_flip1_seq[] = {
|
||||
// U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
// U8X8_END_TRANSFER(), /* disable chip */
|
||||
// U8X8_END() /* end of sequence */
|
||||
// };
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_il3820_296x128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 120,
|
||||
/* pre_chip_disable_wait_ns = */ 60,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100,
|
||||
/* sda_setup_time_ns = */ 50, /* IL3820 */
|
||||
/* sck_pulse_width_ns = */ 125, /* IL3820: 125ns, clock cycle = 250ns */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150,
|
||||
/* tile_width = */ 37, /* 37*8 = 296 */
|
||||
/* tile_hight = */ 16, /* 16*8 = 128 */
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 296,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
|
||||
static uint8_t *u8x8_convert_tile_for_il3820(uint8_t *t)
|
||||
{
|
||||
uint8_t i;
|
||||
static uint8_t buf[8];
|
||||
uint8_t *pbuf = buf;
|
||||
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
*pbuf++ = ~(*t++);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void u8x8_d_il3820_draw_tile(u8x8_t *u8x8, uint8_t arg_int, void *arg_ptr) U8X8_NOINLINE;
|
||||
static void u8x8_d_il3820_draw_tile(u8x8_t *u8x8, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint16_t x;
|
||||
uint8_t c, page;
|
||||
uint8_t *ptr;
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
page = u8x8->display_info->tile_height;
|
||||
page --;
|
||||
page -= (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
//u8x8_cad_SendCmd(u8x8, 0x011 ); /* cursor increment mode */
|
||||
//u8x8_cad_SendArg(u8x8, 7);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x04f ); /* set cursor column */
|
||||
u8x8_cad_SendArg(u8x8, x&255);
|
||||
u8x8_cad_SendArg(u8x8, x>>8);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x04e ); /* set cursor row */
|
||||
u8x8_cad_SendArg(u8x8, page);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x024 );
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 8, u8x8_convert_tile_for_il3820(ptr));
|
||||
ptr += 8;
|
||||
x += 8;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_il3820_exec_1000dly_seq[] = {
|
||||
// assumes, that the start transfer has happend
|
||||
U8X8_CA(0x22, 0x04), /* display update seq. option: pattern display */
|
||||
U8X8_C(0x20), /* execute sequence */
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static void u8x8_d_il3820_first_init(u8x8_t *u8x8)
|
||||
{
|
||||
u8x8_ClearDisplay(u8x8);
|
||||
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x032); // program update sequence
|
||||
u8x8_cad_SendMultipleArg(u8x8, 8, 0x055); // all black
|
||||
u8x8_cad_SendMultipleArg(u8x8, 12, 0x0aa); // all white
|
||||
u8x8_cad_SendMultipleArg(u8x8, 10, 0x022); // 830ms
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_exec_1000dly_seq);
|
||||
|
||||
}
|
||||
|
||||
#ifdef OBSOLETE
|
||||
static void u8x8_d_il3820_second_init(u8x8_t *u8x8)
|
||||
{
|
||||
u8x8_ClearDisplay(u8x8);
|
||||
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x032); // program update sequence
|
||||
u8x8_cad_SendMultipleArg(u8x8, 20, 0x000); // do nothing
|
||||
u8x8_cad_SendMultipleArg(u8x8, 10, 0x011); // 414ms dly
|
||||
/* reuse sequence from above, ok some time is wasted here, */
|
||||
/* delay could be lesser */
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_exec_1000dly_seq);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*=================================================*/
|
||||
/* first version, LUT from WaveShare */
|
||||
|
||||
|
||||
/* http://www.waveshare.com/wiki/File:2.9inch_e-Paper_Module_code.7z */
|
||||
static const uint8_t u8x8_d_il3820_296x128_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_CA(0x10, 0x00), /* Deep Sleep mode Control: Disable */
|
||||
U8X8_C(0x01),
|
||||
U8X8_A(295 % 256), U8X8_A(295/256), U8X8_A(0),
|
||||
|
||||
|
||||
U8X8_CA(0x03, 0x00), /* Gate Driving voltage: 15V (lowest value)*/
|
||||
U8X8_CA(0x04, 0x0a), /* Source Driving voltage: 15V (mid value and POR)*/
|
||||
|
||||
//U8X8_CA(0x22, 0xc0), /* display update seq. option: enable clk, enable CP, .... todo: this is never activated */
|
||||
|
||||
//U8X8_CA(0x0b, 7), /* Set Delay of gate and source non overlap period, POR = 7 */
|
||||
U8X8_CA(0x2c, 0xa8), /* write vcom value*/
|
||||
U8X8_CA(0x3a, 0x16), /* dummy lines POR=22 (0x016) */
|
||||
U8X8_CA(0x3b, 0x08), /* gate time POR=0x08*/
|
||||
U8X8_CA(0x3c, 0x33), /* select boarder waveform */
|
||||
//U8X8_CA(0x22, 0xc4), /* display update seq. option: clk -> CP -> LUT -> initial display -> pattern display */
|
||||
|
||||
|
||||
U8X8_CA(0x11, 0x07), /* Define data entry mode, x&y inc, x first*/
|
||||
|
||||
U8X8_CAA(0x44, 0, 29), /* RAM x start & end, issue 920: end should be (128/8)-1=15. */
|
||||
U8X8_CAAAA(0x45, 0, 0, 295&255, 295>>8), /* RAM y start & end */
|
||||
|
||||
//U8X8_CA(0x4e, 0), /* set x pos, 0..29? */
|
||||
//U8X8_CAA(0x4f, 0, 0), /* set y pos, 0...320??? */
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_il3820_to_display_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
/*
|
||||
0x50, 0xAA, 0x55, 0xAA, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
measured 1582 ms
|
||||
*/
|
||||
U8X8_C(0x32), /* write LUT register*/
|
||||
/* original values */
|
||||
U8X8_A(0x50),
|
||||
U8X8_A(0xaa),
|
||||
U8X8_A(0x55),
|
||||
U8X8_A(0xaa),
|
||||
U8X8_A(0x11),
|
||||
|
||||
U8X8_A(0x11),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
|
||||
/* Timing part of the LUT, 20 Phases with 4 bit each: 10 bytes */
|
||||
U8X8_A(0xff),
|
||||
U8X8_A(0xff),
|
||||
U8X8_A(0x3f),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
|
||||
U8X8_CA(0x22, 0x04), /* display update seq. option: pattern display, assumes clk and charge pump are enabled */
|
||||
U8X8_C(0x20), /* execute sequence */
|
||||
|
||||
U8X8_DLY(250), /* delay for 1620ms. The current sequence takes 1582ms */
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(120),
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_il3820_296x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_il3820_296x128_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_init_seq);
|
||||
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave0_seq);
|
||||
u8x8_d_il3820_first_init(u8x8);
|
||||
|
||||
/* usually the DISPLAY_INIT message leaves the display in power save state */
|
||||
/* however this is not done for e-paper devices, see: */
|
||||
/* https://github.com/olikraus/u8g2/wiki/internal#powersave-mode */
|
||||
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_d_il3820_draw_tile(u8x8, arg_int, arg_ptr);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_REFRESH:
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_to_display_seq);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*=================================================*/
|
||||
/* second version for the IL3820 display */
|
||||
|
||||
|
||||
/* http://www.waveshare.com/wiki/File:2.9inch_e-Paper_Module_code.7z */
|
||||
static const uint8_t u8x8_d_il3820_v2_296x128_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
// U8X8_CA(0x10, 0x00), /* Deep Sleep mode Control: POR: Normal mode */
|
||||
U8X8_C(0x01),
|
||||
U8X8_A(295 % 256), U8X8_A(295/256), U8X8_A(0),
|
||||
|
||||
/* the driving voltagesmust not be that high, in order to aviod level change after */
|
||||
/* some seconds (which happens with 0xea */
|
||||
U8X8_CA(0x03, 0x75), /* Gate Driving voltage: +/-15V =0x00 POR (+22/-20V) = 0x0ea*/
|
||||
U8X8_CA(0x04, 0x0a), /* Source Driving voltage: (POR=0x0a=15V), max=0x0e*/
|
||||
|
||||
U8X8_CA(0x0b, 7), /* Set Delay of gate and source non overlap period, POR = 7 */
|
||||
U8X8_CA(0x2c, 0xa8), /* write vcom value*/
|
||||
U8X8_CA(0x3a, 0x16), /* dummy lines POR=22 (0x016) */
|
||||
U8X8_CA(0x3b, 0x08), /* gate time POR=0x08*/
|
||||
U8X8_CA(0x3c, 0x33), /* select boarder waveform */
|
||||
|
||||
U8X8_CA(0x11, 0x07), /* Define data entry mode, x&y inc, x first*/
|
||||
U8X8_CAA(0x44, 0, 29), /* RAM x start & end, 32*4=128 */
|
||||
U8X8_CAAAA(0x45, 0, 0, 295&255, 295>>8), /* RAM y start & end, 0..295 */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_il3820_v2_to_display_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
/*
|
||||
0xaa, 0x09, 0x09, 0x19, 0x19,
|
||||
0x11, 0x11, 0x11, 0x11, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x75, 0x77, 0x77, 0x77, 0x07,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00
|
||||
measured 1240 ms
|
||||
*/
|
||||
U8X8_C(0x32), /* write LUT register*/
|
||||
/* https://github.com/olikraus/u8g2/issues/347 */
|
||||
U8X8_A(0xaa),
|
||||
U8X8_A(0x09),
|
||||
U8X8_A(0x09),
|
||||
U8X8_A(0x19),
|
||||
U8X8_A(0x19),
|
||||
|
||||
U8X8_A(0x11),
|
||||
U8X8_A(0x11),
|
||||
U8X8_A(0x11),
|
||||
U8X8_A(0x11),
|
||||
U8X8_A(0x00),
|
||||
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
|
||||
/* Timing part of the LUT, 20 Phases with 4 bit each: 10 bytes */
|
||||
U8X8_A(0x75),
|
||||
U8X8_A(0x77),
|
||||
U8X8_A(0x77),
|
||||
U8X8_A(0x77),
|
||||
U8X8_A(0x07),
|
||||
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
|
||||
U8X8_CA(0x22, 0x04), /* display update seq. option: pattern display */
|
||||
U8X8_C(0x20), /* execute sequence */
|
||||
|
||||
U8X8_DLY(250), /* delay for 1400ms. The current sequence takes 1240ms, it was reported, that longer delays are better */
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(150), /* extended, #318 */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_il3820_v2_296x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_il3820_296x128_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_v2_296x128_init_seq);
|
||||
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave0_seq);
|
||||
u8x8_d_il3820_first_init(u8x8);
|
||||
/* u8x8_d_il3820_second_init(u8x8); */ /* not required, u8g2.begin() will also clear the display once more */
|
||||
|
||||
/* usually the DISPLAY_INIT message leaves the display in power save state */
|
||||
/* however this is not done for e-paper devices, see: */
|
||||
/* https://github.com/olikraus/u8g2/wiki/internal#powersave-mode */
|
||||
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_d_il3820_draw_tile(u8x8, arg_int, arg_ptr);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_REFRESH:
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_v2_to_display_seq);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
200
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ist3020.c
Normal file
200
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ist3020.c
Normal file
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ist3020.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2017, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ist3020_erc19264_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a4), /* all pixel off, issue 142 */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ist3020_erc19264_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ist3020_erc19264_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ist3020_erc19264_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ist3020_erc19264_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 150, /* IST3020 datasheet, page 56 */
|
||||
/* pre_chip_disable_wait_ns = */ 150, /* IST3020 datasheet, page 56 */
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 1,
|
||||
/* sda_setup_time_ns = */ 100, /* IST3020 datasheet, page 56 */
|
||||
/* sck_pulse_width_ns = */ 100, /* IST3020 datasheet, page 56 */
|
||||
/* sck_clock_hz = */ 4000000UL, /* */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40, /* IST3020 datasheet, page 54 */
|
||||
/* write_pulse_width_ns = */ 60, /* IST3020 datasheet, page 54 */
|
||||
/* tile_width = */ 24, /* width of 24*8=192 pixel */
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 64,
|
||||
/* pixel_width = */ 192,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ist3020_erc19264_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0e2), /* soft reset */
|
||||
U8X8_C(0x0ab), /* build in osc on, used in ER code, but not mentioned in data sheet */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
|
||||
U8X8_C(0x040), /* set display start line to 0 */
|
||||
|
||||
U8X8_C(0x0a0), /* ADC set to reverse */
|
||||
U8X8_C(0x0c8), /* common output mode */
|
||||
// Flipmode
|
||||
//U8X8_C(0x0a0), /* ADC set to reverse */
|
||||
//U8X8_C(0x0c8), /* common output mode */
|
||||
|
||||
U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */
|
||||
U8X8_C(0x0a3), /* FIX: LCD bias 1/7, old value was 1/9 (0x0a2) */
|
||||
|
||||
U8X8_C(0x028|4), /* all power control circuits on */
|
||||
U8X8_DLY(50),
|
||||
U8X8_C(0x028|6), /* all power control circuits on */
|
||||
U8X8_DLY(50),
|
||||
U8X8_C(0x028|7), /* all power control circuits on */
|
||||
U8X8_DLY(50),
|
||||
|
||||
U8X8_C(0x020), /* v0 voltage resistor ratio */
|
||||
U8X8_CA(0x081, 0x019), /* set contrast, contrast value (from ER code: 45) */
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ist3020_erc19264(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ist3020_erc19264_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist3020_erc19264_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist3020_erc19264_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist3020_erc19264_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist3020_erc19264_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist3020_erc19264_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int >> 2 ); /* st7567 has range from 0 to 63 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
202
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ist7920.c
Normal file
202
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ist7920.c
Normal file
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ist7920.c
|
||||
|
||||
this is NOT ST7920!
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2019, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ist7920_128x128_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x03d), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ist7920_128x128_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x03c), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ist7920_128x128_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x064), /* Display Ctrl: Bit3: SHL 2:ADC 1:EON, 0:REV */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ist7920_128x128_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x068), /* Display Ctrl: Bit3: SHL 2:ADC 1:EON, 0:REV */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ist7920_128x128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 90, /* IST7920 datasheet, page 48 */
|
||||
/* pre_chip_disable_wait_ns = */ 90, /* IST7920 datasheet, page 48 */
|
||||
/* reset_pulse_width_ms = */ 10,
|
||||
/* post_reset_wait_ms = */ 20, /* IST7920 Startup Seq.. */
|
||||
/* sda_setup_time_ns = */ 45, /* IST7920 datasheet, page 48 */
|
||||
/* sck_pulse_width_ns = */ 130, /* IST7920 datasheet, page 48 */
|
||||
/* sck_clock_hz = */ 3000000UL, /* IST7920 datasheet: 260ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge (not verified) */
|
||||
/* i2c_bus_clock_100kHz = */ 4, /* 400kHz according to IST7920 datasheet */
|
||||
/* data_setup_time_ns = */ 60, /* IST7920 datasheet, page 47 */
|
||||
/* write_pulse_width_ns = */ 150, /* IST7920 datasheet, page 47 */
|
||||
/* tile_width = */ 16, /* width of 16*8=128 pixel */
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
/* 1/128 Duty, 1/10 Bias, 128x128 round display */
|
||||
static const uint8_t u8x8_d_ist7920_128x128_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x076), /* Software Reset */
|
||||
U8X8_DLY(50),
|
||||
U8X8_C(0x03c), /* display off */
|
||||
|
||||
|
||||
U8X8_CA(0x090, 128), /* Set Duty */
|
||||
//U8X8_CAA(0x0b2, 0x011, 0x00), /* Set Frame Control */
|
||||
|
||||
U8X8_CA(0x030, 16), /* Set Bias 0: 1/8, 8: 1/9, 16: 1/10, 24: 1/11, 48: 1/12 ... */
|
||||
U8X8_CA(0x031, 0x03f), /* Set voltage generate clock(31H/11H) */
|
||||
//U8X8_CA(0x032, 0x015), /* Temperature compensation */
|
||||
U8X8_CA(0x033, 0x020), /* Power Control */
|
||||
U8X8_DLY(100),
|
||||
U8X8_CA(0x033, 0x02c), /* Power Control */
|
||||
U8X8_DLY(100),
|
||||
U8X8_C(0xfd), /* set booster */
|
||||
U8X8_DLY(100),
|
||||
U8X8_CA(0x033, 0x02f), /* Power Control */
|
||||
U8X8_DLY(200),
|
||||
|
||||
U8X8_C(0x064), /* Display Ctrl: Bit3: SHL 2:ADC 1:EON, 0:REV */
|
||||
|
||||
U8X8_CAA(0x074, 0x000, 0x00f), /* AY Window */
|
||||
U8X8_CAA(0x075, 0x000, 0x07f), /* AX Window */
|
||||
|
||||
U8X8_CA(0x040, 64), /* Start line at 64 */
|
||||
|
||||
U8X8_CA(0x0b1, 100), /* electronic volume */
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ist7920_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ist7920_128x128_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist7920_128x128_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist7920_128x128_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist7920_128x128_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist7920_128x128_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist7920_128x128_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b1 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* st7920 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x0c0 );
|
||||
u8x8_cad_SendArg(u8x8, x );
|
||||
u8x8_cad_SendCmd(u8x8, 0x001 );
|
||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos) );
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
344
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ks0108.c
Normal file
344
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ks0108.c
Normal file
@@ -0,0 +1,344 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ks0108.c
|
||||
|
||||
The classic 5V LCD
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ks0108_init_seq[] = {
|
||||
U8X8_C(0x0c0), /* start at the top */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ks0108_powersave0_seq[] = {
|
||||
U8X8_C(0x03f), /* display on */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ks0108_powersave1_seq[] = {
|
||||
U8X8_C(0x03e), /* display off */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
struct u8x8_ks0108_vars
|
||||
{
|
||||
uint8_t *ptr;
|
||||
uint8_t x;
|
||||
uint8_t c;
|
||||
uint8_t arg_int;
|
||||
};
|
||||
|
||||
static void u8x8_ks0108_out(u8x8_t *u8x8, struct u8x8_ks0108_vars *v, void *arg_ptr)
|
||||
{
|
||||
uint8_t cnt;
|
||||
u8x8_cad_SendCmd(u8x8, 0x040 | ((v->x << 3) & 63) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b8 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
while( v->arg_int > 0 )
|
||||
{
|
||||
/* calculate tiles to next boundary (end or chip limit) */
|
||||
cnt = v->x;
|
||||
cnt += 8;
|
||||
cnt &= 0x0f8;
|
||||
cnt -= v->x;
|
||||
|
||||
if ( cnt > v->c )
|
||||
cnt = v->c;
|
||||
|
||||
/* of cours we still could use cnt=1 here... */
|
||||
/* but setting cnt to 1 is not very efficient */
|
||||
//cnt = 1;
|
||||
|
||||
v->x +=cnt;
|
||||
v->c-=cnt;
|
||||
cnt<<=3;
|
||||
u8x8_cad_SendData(u8x8, cnt, v->ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
v->ptr += cnt;
|
||||
|
||||
if ( v->c == 0 )
|
||||
{
|
||||
v->ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
v->c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
v->arg_int--;
|
||||
}
|
||||
if ( ((v->x) & 7) == 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ks0108_128x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0, /* KS0108: Not used */
|
||||
/* chip_disable_level = */ 1, /* KS0108: Not used */
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 100,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6, /* could be faster for the KS0108 */
|
||||
/* sda_setup_time_ns = */ 12,
|
||||
/* sck_pulse_width_ns = */ 75, /* KS0108: Not used */
|
||||
/* sck_clock_hz = */ 4000000UL, /* KS0108: Not used */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4, /* KS0108: Not used */
|
||||
/* data_setup_time_ns = */ 200,
|
||||
/* write_pulse_width_ns = */ 250, /* KS0108: actially 450 ns, but additional 200 ns are added by the byte transfer function */
|
||||
/* tile_width = */ 16, /* width of 16*8=128 pixel */
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ks0108_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
struct u8x8_ks0108_vars v;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ks0108_128x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_init_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 2, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_init_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave0_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 2, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave0_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave1_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 2, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave1_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
||||
|
||||
}
|
||||
break;
|
||||
// The KS0108 can not mirror the cols and rows, use U8g2 for rotation
|
||||
// case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
// break;
|
||||
// The KS0108 has no internal contrast command
|
||||
// case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
// break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
|
||||
v.ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
v.x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
v.c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
v.arg_int = arg_int;
|
||||
|
||||
|
||||
if ( v.x < 8 )
|
||||
{
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
|
||||
u8x8_ks0108_out(u8x8, &v, arg_ptr);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
||||
}
|
||||
if ( v.x < 16 )
|
||||
{
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 2, NULL);
|
||||
u8x8_ks0108_out(u8x8, &v, arg_ptr);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
||||
}
|
||||
//if ( v.x < 24 )
|
||||
//{
|
||||
//u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 4, NULL);
|
||||
//u8x8_ks0108_out(u8x8, &v, arg_ptr);
|
||||
//u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
||||
//}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const u8x8_display_info_t u8x8_ks0108_192x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0, /* KS0108: Not used */
|
||||
/* chip_disable_level = */ 1, /* KS0108: Not used */
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 100,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6, /* could be faster for the KS0108 */
|
||||
/* sda_setup_time_ns = */ 12,
|
||||
/* sck_pulse_width_ns = */ 75, /* KS0108: Not used */
|
||||
/* sck_clock_hz = */ 4000000UL, /* KS0108: Not used */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4, /* KS0108: Not used */
|
||||
/* data_setup_time_ns = */ 200,
|
||||
/* write_pulse_width_ns = */ 250, /* KS0108: actially 450 ns, but additional 200 ns are added by the byte transfer function */
|
||||
/* tile_width = */ 24, /* width of 24*8=192 pixel */
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 192,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
|
||||
/* east rising (buydisplay.com) ERM19264 */
|
||||
/* left: 011, middle: 101, right: 110, no chip select: 111 */
|
||||
uint8_t u8x8_d_ks0108_erm19264(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
struct u8x8_ks0108_vars v;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ks0108_192x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 3, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_init_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 5, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_init_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 6, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_init_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 3, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave0_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 5, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave0_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 6, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave0_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 3, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave1_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 5, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave1_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 6, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave1_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
||||
|
||||
}
|
||||
break;
|
||||
// The KS0108 can not mirror the cols and rows, use U8g2 for rotation
|
||||
// case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
// break;
|
||||
// The KS0108 has no internal contrast command
|
||||
// case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
// break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
|
||||
v.ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
v.x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
v.c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
v.arg_int = arg_int;
|
||||
|
||||
/*
|
||||
3-bit CS value:
|
||||
In u8x8_byte_set_ks0108_cs(u8x8_t *u8x8, uint8_t arg) the lowest
|
||||
bit is assigned to CS and highest bit if the 3-bit value to CS2
|
||||
|
||||
CS: left part of the display --> 6
|
||||
CS1: middle part --> 5
|
||||
CS2: right part of the display --> 3
|
||||
|
||||
Reference: https://github.com/olikraus/u8g2/issues/631
|
||||
*/
|
||||
if ( v.x < 8 )
|
||||
{
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 6, NULL); // 3-->6, issue 631
|
||||
u8x8_ks0108_out(u8x8, &v, arg_ptr);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
||||
}
|
||||
if ( v.x < 16 )
|
||||
{
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 5, NULL);
|
||||
u8x8_ks0108_out(u8x8, &v, arg_ptr);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
||||
}
|
||||
if ( v.x < 24 )
|
||||
{
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 3, NULL); // 6-->3, // issue 631
|
||||
u8x8_ks0108_out(u8x8, &v, arg_ptr);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
470
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_lc7981.c
Normal file
470
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_lc7981.c
Normal file
@@ -0,0 +1,470 @@
|
||||
/*
|
||||
|
||||
u8x8_d_lc7981.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/* no powersave mode for the LC7981 */
|
||||
// static const uint8_t u8x8_d_lc7981_powersave0_seq[] = {
|
||||
// U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
// U8X8_END_TRANSFER(), /* disable chip */
|
||||
// U8X8_END() /* end of sequence */
|
||||
// };
|
||||
|
||||
// static const uint8_t u8x8_d_lc7981_powersave1_seq[] = {
|
||||
// U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
// U8X8_END_TRANSFER(), /* disable chip */
|
||||
// U8X8_END() /* end of sequence */
|
||||
// };
|
||||
|
||||
/* no hardware flip for the LC7981 */
|
||||
// static const uint8_t u8x8_d_lc7981_flip0_seq[] = {
|
||||
// U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
// U8X8_END_TRANSFER(), /* disable chip */
|
||||
// U8X8_END() /* end of sequence */
|
||||
// };
|
||||
|
||||
// static const uint8_t u8x8_d_lc7981_flip1_seq[] = {
|
||||
// U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
// U8X8_END_TRANSFER(), /* disable chip */
|
||||
// U8X8_END() /* end of sequence */
|
||||
// };
|
||||
|
||||
|
||||
/* http://graphics.stanford.edu/~seander/bithacks.html */
|
||||
static uint8_t reverse_byte(uint8_t v)
|
||||
{
|
||||
// if ( v != 0 && v != 255 ) does not help much
|
||||
{
|
||||
// swap odd and even bits
|
||||
v = ((v >> 1) & 0x055) | ((v & 0x055) << 1);
|
||||
// swap consecutive pairs
|
||||
v = ((v >> 2) & 0x033) | ((v & 0x033) << 2);
|
||||
// swap nibbles ...
|
||||
v = ((v >> 4) & 0x00F) | ((v & 0x00F) << 4);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
static uint8_t u8x8_d_lc7981_common(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t c, i, j;
|
||||
uint16_t y;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
y*=8;
|
||||
y*= u8x8->display_info->tile_width;
|
||||
/* x = ((u8x8_tile_t *)arg_ptr)->x_pos; x is ignored... no u8x8 support */
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
/*
|
||||
Tile structure is reused here for the t6963, however u8x8 is not supported
|
||||
tile_ptr points to data which has cnt*8 bytes (same as SSD1306 tiles)
|
||||
Buffer is expected to have 8 lines of code fitting to the t6963 internal memory
|
||||
"cnt" includes the number of horizontal bytes. width is equal to cnt*8
|
||||
|
||||
x is assumed to be zero
|
||||
|
||||
TODO: Consider arg_int, however arg_int is not used by u8g2
|
||||
*/
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
u8x8_cad_SendCmd(u8x8, 0x0a ); /* display ram (cursor) address low byte */
|
||||
u8x8_cad_SendArg(u8x8, y&255);
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b ); /* display ram (cursor) address high byte */
|
||||
u8x8_cad_SendArg(u8x8, y>>8);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x0c ); /* write start */
|
||||
/*
|
||||
The LC7981 has the MSB at the right position, which is exactly the opposite to the T6963.
|
||||
Instead of writing a third hvline procedure for this device, we just revert the bytes before
|
||||
transmit. This is slow because:
|
||||
- the bit reverse itself
|
||||
- the single byte transfer
|
||||
The one byte is transmitted via SendArg, which is ok, because CAD = 100
|
||||
*/
|
||||
for( j = 0; j < c; j++ )
|
||||
u8x8_cad_SendArg(u8x8, reverse_byte(*ptr++));
|
||||
|
||||
//u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes, send one line of data */
|
||||
//ptr += u8x8->display_info->tile_width;
|
||||
|
||||
y += u8x8->display_info->tile_width;
|
||||
}
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
/* handled in the calling procedure
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_128x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq);
|
||||
break;
|
||||
*/
|
||||
/* power save is not there...
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_powersave1_seq);
|
||||
break;
|
||||
*/
|
||||
/* hardware flip not is not available
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
*/
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
/* no contrast setting :-(
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int );
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
*/
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*================================================*/
|
||||
/* LC7981 160x80 LCD*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_lc7981_160x80_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0, /* LC7981 has a low active CS*/
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* from here... */
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 10,
|
||||
/* sda_setup_time_ns = */ 30,
|
||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* ... to here, values are ignored, because this is a parallel interface only */
|
||||
|
||||
/* data_setup_time_ns = */ 220,
|
||||
/* write_pulse_width_ns = */ 20,
|
||||
/* tile_width = */ 20, /* width of 20*8=160 pixel */
|
||||
/* tile_hight = */ 10,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 160,
|
||||
/* pixel_height = */ 80
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_lc7981_160x80_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_DLY(50),
|
||||
|
||||
U8X8_CA(0x00, 0x32), /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1) */
|
||||
U8X8_CA(0x01, 0x07), /* character/bits per pixel pitch */
|
||||
U8X8_CA(0x02, 160/8-1), /* number of chars/byte width of the screen */
|
||||
U8X8_CA(0x03, 0x50), /* time division: 50 (1/80 duty cycle) */
|
||||
U8X8_CA(0x08, 0x00), /* display start low */
|
||||
U8X8_CA(0x09, 0x00), /* display start high */
|
||||
|
||||
U8X8_DLY(10),
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_lc7981_160x80(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call common procedure first and handle messages there */
|
||||
if ( u8x8_d_lc7981_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_160x80_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_160x80_init_seq);
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*================================================*/
|
||||
/* LC7981 160x160 LCD*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_lc7981_160x160_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0, /* LC7981 has a low active CS*/
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* from here... */
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 10,
|
||||
/* sda_setup_time_ns = */ 30,
|
||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* ... to here, values are ignored, because this is a parallel interface only */
|
||||
|
||||
/* data_setup_time_ns = */ 220,
|
||||
/* write_pulse_width_ns = */ 20,
|
||||
/* tile_width = */ 20, /* width of 20*8=160 pixel */
|
||||
/* tile_hight = */ 20,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 160,
|
||||
/* pixel_height = */ 160
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_lc7981_160x160_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_DLY(50),
|
||||
|
||||
U8X8_CA(0x00, 0x32), /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1) */
|
||||
U8X8_CA(0x01, 0x07), /* character/bits per pixel pitch */
|
||||
U8X8_CA(0x02, 160/8-1), /* number of chars/byte width of the screen */
|
||||
U8X8_CA(0x03, 159), /* time division */
|
||||
U8X8_CA(0x08, 0x00), /* display start low */
|
||||
U8X8_CA(0x09, 0x00), /* display start high */
|
||||
|
||||
U8X8_DLY(10),
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_lc7981_160x160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call common procedure first and handle messages there */
|
||||
if ( u8x8_d_lc7981_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_160x160_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_160x160_init_seq);
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*================================================*/
|
||||
/* LC7981 240x128 LCD*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_lc7981_240x128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0, /* LC7981 has a low active CS*/
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* from here... */
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 10,
|
||||
/* sda_setup_time_ns = */ 30,
|
||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* ... to here, values are ignored, because this is a parallel interface only */
|
||||
|
||||
/* data_setup_time_ns = */ 220,
|
||||
/* write_pulse_width_ns = */ 20,
|
||||
/* tile_width = */ 30, /* width of 30*8=240 pixel */
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 240,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_lc7981_240x128_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_DLY(50),
|
||||
|
||||
U8X8_CA(0x00, 0x32), /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1) */
|
||||
U8X8_CA(0x01, 0x07), /* character/bits per pixel pitch */
|
||||
U8X8_CA(0x02, 240/8-1), /* number of chars/byte width of the screen */
|
||||
U8X8_CA(0x03, 128), /* time division, issue https://github.com/olikraus/u8g2/issues/1581 */
|
||||
U8X8_CA(0x08, 0x00), /* display start low */
|
||||
U8X8_CA(0x09, 0x00), /* display start high */
|
||||
|
||||
U8X8_DLY(10),
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_lc7981_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call common procedure first and handle messages there */
|
||||
if ( u8x8_d_lc7981_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_240x128_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_240x128_init_seq);
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*================================================*/
|
||||
/* LC7981 240x64 LCD*/
|
||||
/* https://github.com/olikraus/u8g2/issues/642 */
|
||||
|
||||
static const u8x8_display_info_t u8x8_lc7981_240x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0, /* LC7981 has a low active CS*/
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* from here... */
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 10,
|
||||
/* sda_setup_time_ns = */ 30,
|
||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* ... to here, values are ignored, because this is a parallel interface only */
|
||||
|
||||
/* data_setup_time_ns = */ 220,
|
||||
/* write_pulse_width_ns = */ 20,
|
||||
/* tile_width = */ 30, /* width of 30*8=240 pixel */
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 240,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_lc7981_240x64_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_DLY(50),
|
||||
|
||||
U8X8_CA(0x00, 0x32), /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1) */
|
||||
U8X8_CA(0x01, 0x07), /* character/bits per pixel pitch */
|
||||
U8X8_CA(0x02, 240/8-1), /* number of chars/byte width of the screen */
|
||||
U8X8_CA(0x03, 0x7f), /* time division */
|
||||
U8X8_CA(0x08, 0x00), /* display start low */
|
||||
U8X8_CA(0x09, 0x00), /* display start high */
|
||||
|
||||
U8X8_DLY(10),
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_lc7981_240x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call common procedure first and handle messages there */
|
||||
if ( u8x8_d_lc7981_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_240x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_240x64_init_seq);
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
298
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ld7032_60x32.c
Normal file
298
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ld7032_60x32.c
Normal file
@@ -0,0 +1,298 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ld7032_60x32.c
|
||||
Note: Flip Mode is NOT supported
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
/* testboard U8GLIB_LD7032_60x32 u8g(11, 12, 9, 10, 8); // SPI Com: SCK = 11, MOSI = 12, CS = 9, A0 = 10, RST = 8 (SW SPI Nano Board) */
|
||||
/* http://www.seeedstudio.com/document/pdf/0.5OLED%20SPEC.pdf */
|
||||
#ifdef OBSOLETE
|
||||
static const uint8_t u8x8_d_ld7032_60x32_init_seq_old[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
//U8X8_CA(0x002, 0x001), /* Dot Matrix Display ON */
|
||||
U8X8_CA(0x014, 0x000), /* Stand-by OFF */
|
||||
U8X8_CA(0x01a, 0x004), /* Dot Matrix Frame Rate, special value for this OLED from manual*/
|
||||
U8X8_CA(0x01d, 0x000), /* Graphics Memory Writing Direction: reset default (right down, horizontal) */
|
||||
U8X8_CA(0x009, 0x000), /* Display Direction: reset default (x,y: min --> max) */
|
||||
U8X8_CAA(0x030, 0x000, 0x03b), /* Display Size X, Column Start - End*/
|
||||
U8X8_CAA(0x032, 0x000, 0x01f), /* Display Size Y, Row Start - End*/
|
||||
U8X8_CA(0x010, 0x000), /* Peak Pulse Width Set: 0 SCLK */
|
||||
U8X8_CA(0x016, 0x000), /* Peak Pulse Delay Set: 0 SCLK */
|
||||
U8X8_CA(0x012, 0x040), /* Dot Matrix Current Level Set: 0x050 * 1 uA = 80 uA */
|
||||
U8X8_CA(0x018, 0x003), /* Pre-Charge Pulse Width: 3 SCLK */
|
||||
U8X8_CA(0x044, 0x002), /* Pre-Charge Mode: Every Time */
|
||||
U8X8_CA(0x048, 0x003), /* Row overlap timing: Pre-Charge + Peak Delay + Peak boot Timing */
|
||||
U8X8_CA(0x03f, 0x011), /* VCC_R_SEL: ??? */
|
||||
U8X8_CA(0x03d, 0x000), /* VSS selection: 2.8V */
|
||||
//U8X8_CA(0x002, 0x001), /* Dot Matrix Display ON */
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
#endif
|
||||
|
||||
/* new sequence https://github.com/olikraus/u8g2/issues/865 */
|
||||
static const uint8_t u8x8_d_ld7032_60x32_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_CA(0x02, 0x00), /* Dot Matrix Display OFF */
|
||||
U8X8_CA(0x14, 0x00), /* Stand-by OFF, OSCA Start */
|
||||
U8X8_CA(0x1a, 0x04), /* Dot Matrix Frame Rate, special value for this OLED from manual 4 => 120Hz*/
|
||||
U8X8_CA(0x1d, 0x00), /* Graphics Memory Writing Direction: reset default (right down, horizontal) */
|
||||
U8X8_CA(0x09, 0x00), /* Display Direction: reset default (x,y: min --> max) */
|
||||
U8X8_CAA(0x30, 0x00, 0x3B), /* Display Size X, Column Start - End 0-0x3b(59)*/
|
||||
U8X8_CAA(0x32, 0x00, 0x1F), /* Display Size Y, Row Start - End 0-0x1f(31)*/
|
||||
U8X8_CA(0x34, 0x00), /* Data Reading/Writing Box X start */
|
||||
U8X8_CA(0x35, 0x07), /* Data Reading/Writing Box X end */
|
||||
U8X8_CA(0x36, 0x00), /* Data Reading/Writing Box Y start */
|
||||
U8X8_CA(0x37, 0x1F), /* Data Reading/Writing Box Y end */
|
||||
U8X8_CA(0x38, 0x00), /* Display Start Address X */
|
||||
U8X8_CA(0x39, 0x00), /* Display Start Address Y */
|
||||
U8X8_CA(0x10, 0x00), /* Peak Pulse Width Set: 0 SCLK */
|
||||
U8X8_CA(0x16, 0x00), /* Peak Pulse Delay Set: 0 SCLK */
|
||||
U8X8_CA(0x12, 0x40), /* 0x32, 0x50 or 0x40 Dot Matrix Current Level Set: 0x050 * 1 uA = 80 uA */
|
||||
U8X8_CA(0x18, 0x03), /* Pre-Charge Pulse Width: 3 SCLK */
|
||||
U8X8_CA(0x44, 0x02), /* Pre-Charge Mode: Every Time */
|
||||
U8X8_CA(0x48, 0x03), /* Row overlap timing: Pre-Charge + Peak Delay + Peak boot Timing */
|
||||
U8X8_CA(0x17, 0x00), /* Row Scan */
|
||||
U8X8_CA(0x13, 0x00), /* Row Scan Sequence Setting */
|
||||
U8X8_CA(0x1C, 0x00), /* Data Reverse */
|
||||
U8X8_CA(0x3f, 0x11), /* VCC_R_SEL: Internal Regulator enabled(D4=1) and VCC_R=VCC_C*0.7(D0=1) */
|
||||
U8X8_CA(0x3d, 0x00), /* VSS selection: 2.8V */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ld7032_60x32_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x002, 0x001), /* Dot Matrix Display ON */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ld7032_60x32_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x002, 0x000), /* Dot Matrix Display ON */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ld7032_60x32_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x009, 0x000), /* Display Direction: reset default (x,y: min --> max) */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ld7032_60x32_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
//U8X8_CA(0x009, 0x002), /* Display Direction: reset default (x,y: min --> max) */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ld7032_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ld7032_60x32_display_info);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x012 );
|
||||
if ( arg_int > 0x07f ) /* default is 0x040, limit to 0x07f to be on the safe side (hopefully) */
|
||||
arg_int= 0x07f;
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* values from 0x00 to 0x0ff are allowed, bit will all values be safe??? */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x += u8x8->x_offset/8;
|
||||
u8x8_cad_SendCmd(u8x8, 0x034 );
|
||||
u8x8_cad_SendArg(u8x8, x );
|
||||
u8x8_cad_SendCmd(u8x8, 0x035 );
|
||||
u8x8_cad_SendArg(u8x8, 0x007 );
|
||||
u8x8_cad_SendCmd(u8x8, 0x036 );
|
||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)*8 );
|
||||
u8x8_cad_SendCmd(u8x8, 0x037 );
|
||||
u8x8_cad_SendArg(u8x8, 0x01f );
|
||||
u8x8_cad_SendCmd(u8x8, 0x008 );
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ld7032_60x32_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 15,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100,
|
||||
/* sda_setup_time_ns = */ 30, /* 20ns, but cycle time is 60ns, so use 60/2 */
|
||||
/* sck_pulse_width_ns = */ 30, /* 20ns, but cycle time is 60ns, so use 60/2 */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 20,
|
||||
/* write_pulse_width_ns = */ 40,
|
||||
/* tile_width = */ 8,
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 60,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ld7032_60x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ld7032_60x32_display_info);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ld7032_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* alternative version, issue #1189 */
|
||||
|
||||
/* new sequence https://github.com/olikraus/u8g2/issues/1189 */
|
||||
static const uint8_t u8x8_d_ld7032_60x32_alt_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_CA(0x02, 0x00),
|
||||
U8X8_CA(0x14, 0x00),
|
||||
U8X8_CA(0x1A, 0x05),
|
||||
U8X8_CA(0x1D, 0x00),
|
||||
U8X8_CA(0x09, 0x00),
|
||||
U8X8_CAA(0x30, 0x00, 0x3F),
|
||||
U8X8_CAA(0x32, 0x08, 0x27),
|
||||
U8X8_CA(0x34, 0x00),
|
||||
U8X8_CA(0x35, 0x07),
|
||||
U8X8_CA(0x36, 0x08),
|
||||
U8X8_CA(0x37, 0x27),
|
||||
U8X8_CA(0x38, 0x00),
|
||||
U8X8_CA(0x39, 0x20),
|
||||
U8X8_CA(0x10, 0x05),
|
||||
U8X8_CA(0x16, 0x00),
|
||||
U8X8_CA(0x18, 0x08),
|
||||
U8X8_CA(0x12, 0x2F),
|
||||
U8X8_CA(0x3D, 0x01),
|
||||
U8X8_CA(0x3F, 0x10),
|
||||
U8X8_CA(0x44, 0x02),
|
||||
U8X8_CA(0x48, 0x03),
|
||||
U8X8_CA(0x17, 0x00),
|
||||
U8X8_CA(0x13, 0x01),
|
||||
U8X8_CA(0x3F, 0x11),
|
||||
U8X8_CA(0x3D, 0x00),
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */};
|
||||
|
||||
uint8_t u8x8_d_ld7032_60x32_alt(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ld7032_60x32_display_info);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( msg ==U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_alt_init_seq);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return u8x8_d_ld7032_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
234
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ls013b7dh03.c
Normal file
234
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ls013b7dh03.c
Normal file
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ls013b7dh03.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
The LS013B7DH02 is a simple display and controller
|
||||
--> no support for contrast adjustment, flip and power down.
|
||||
*/
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
#define SWAP8(a) ((((a) & 0x80) >> 7) | (((a) & 0x40) >> 5) | (((a) & 0x20) >> 3) | (((a) & 0x10) >> 1) | (((a) & 0x08) << 1) | (((a) & 0x04) << 3) | (((a) & 0x02) << 5) | (((a) & 0x01) << 7))
|
||||
|
||||
#define LS013B7DH03_CMD_UPDATE (0x01)
|
||||
#define LS013B7DH03_CMD_ALL_CLEAR (0x04)
|
||||
#define LS013B7DH03_VAL_TRAILER (0x00)
|
||||
|
||||
static const u8x8_display_info_t u8x8_ls013b7dh03_128x128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 1,
|
||||
/* chip_disable_level = */ 0,
|
||||
/* post_chip_enable_wait_ns = */ 50,
|
||||
/* pre_chip_disable_wait_ns = */ 50,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
|
||||
/* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
|
||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 2, /* active low, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 100,
|
||||
/* write_pulse_width_ns = */ 100,
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ls013b7dh03_128x128(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t y, c, i;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ls013b7dh03_128x128_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
|
||||
/* clear screen */
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, SWAP8(LS013B7DH03_CMD_ALL_CLEAR) );
|
||||
u8x8_cad_SendCmd(u8x8, LS013B7DH03_VAL_TRAILER);
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
/* not available for the ls013b7dh03 */
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
/* each tile is 8 lines, with the data starting at the left edge */
|
||||
y = ((((u8x8_tile_t *)arg_ptr)->y_pos) * 8) + 1;
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
|
||||
/* send data mode byte */
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, SWAP8(LS013B7DH03_CMD_UPDATE) );
|
||||
|
||||
/* send 8 lines of 16 bytes (=128 pixels) */
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
u8x8_cad_SendCmd(u8x8, SWAP8(y + i) );
|
||||
u8x8_cad_SendData(u8x8, c, ptr);
|
||||
u8x8_cad_SendCmd(u8x8, LS013B7DH03_VAL_TRAILER);
|
||||
|
||||
ptr += c;
|
||||
}
|
||||
|
||||
/* finish with a trailing byte */
|
||||
u8x8_cad_SendCmd(u8x8, LS013B7DH03_VAL_TRAILER);
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ls027b7dh01_400x240_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 1,
|
||||
/* chip_disable_level = */ 0,
|
||||
/* post_chip_enable_wait_ns = */ 50,
|
||||
/* pre_chip_disable_wait_ns = */ 50,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
|
||||
/* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
|
||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 2, /* active low, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 100,
|
||||
/* write_pulse_width_ns = */ 100,
|
||||
/* tile_width = */ 50,
|
||||
/* tile_hight = */ 30,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 400,
|
||||
/* pixel_height = */ 240
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ls027b7dh01_400x240(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ls027b7dh01_400x240_display_info);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_ls013b7dh03_128x128(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const u8x8_display_info_t u8x8_ls027b7dh01_m0_400x240_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 1,
|
||||
/* chip_disable_level = */ 0,
|
||||
/* post_chip_enable_wait_ns = */ 50,
|
||||
/* pre_chip_disable_wait_ns = */ 50,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
|
||||
/* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
|
||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active low, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 100,
|
||||
/* write_pulse_width_ns = */ 100,
|
||||
/* tile_width = */ 50,
|
||||
/* tile_hight = */ 30,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 400,
|
||||
/* pixel_height = */ 240
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ls027b7dh01_m0_400x240(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ls027b7dh01_m0_400x240_display_info);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_ls013b7dh03_128x128(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ls013b7dh05_144x168_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 1,
|
||||
/* chip_disable_level = */ 0,
|
||||
/* post_chip_enable_wait_ns = */ 50,
|
||||
/* pre_chip_disable_wait_ns = */ 50,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
|
||||
/* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
|
||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 2, /* active low, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 100,
|
||||
/* write_pulse_width_ns = */ 100,
|
||||
/* tile_width = */ 18,
|
||||
/* tile_hight = */ 21,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 144,
|
||||
/* pixel_height = */ 168
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ls013b7dh05_144x168(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ls013b7dh05_144x168_display_info);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_ls013b7dh03_128x128(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
459
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_max7219.c
Normal file
459
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_max7219.c
Normal file
@@ -0,0 +1,459 @@
|
||||
/*
|
||||
|
||||
u8x8_d_max7219.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2017, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_max7219_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(15, 0), /* test mode off */
|
||||
U8X8_CA(15, 0), /* test mode off */
|
||||
U8X8_CA(15, 0), /* test mode off */
|
||||
U8X8_CA(15, 0), /* test mode off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(12, 0), /* */
|
||||
U8X8_CA(12, 0), /* */
|
||||
U8X8_CA(12, 0), /* */
|
||||
U8X8_CA(12, 0), /* */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(10, 10), /* medium high intensity */
|
||||
U8X8_CA(10, 10), /* medium high intensity */
|
||||
U8X8_CA(10, 10), /* medium high intensity */
|
||||
U8X8_CA(10, 10), /* medium high intensity */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
|
||||
|
||||
//U8X8_CA(12, 0), /* shutdown */
|
||||
|
||||
//U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_max7219_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(12, 1), /* display on */
|
||||
U8X8_CA(12, 1), /* display on */
|
||||
U8X8_CA(12, 1), /* display on */
|
||||
U8X8_CA(12, 1), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_max7219_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(12, 0), /* shutdown */
|
||||
U8X8_CA(12, 0), /* shutdown */
|
||||
U8X8_CA(12, 0), /* shutdown */
|
||||
U8X8_CA(12, 0), /* shutdown */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8x8_d_max7219_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t c, j, i;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_pcf8812_96x65_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave1_seq);
|
||||
break;
|
||||
*/
|
||||
/* not supported by MAX7219
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
break;
|
||||
*/
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
for( i = 0; i < u8x8->display_info->tile_width; i++ )
|
||||
{
|
||||
u8x8_cad_SendCmd(u8x8, 10 ); /* brightness */
|
||||
u8x8_cad_SendArg(u8x8, (arg_int>>4) ); /* 0..15 for contrast */
|
||||
}
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
/* transfer always has to start at x pos 0 (u8x8 is not supported) */
|
||||
/* also y pos has to be 0 */
|
||||
/* arg_int is ignored */
|
||||
//x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
for( j = 0; j < c; j++ )
|
||||
{
|
||||
u8x8_cad_SendCmd(u8x8, i+1); /* commands 1..8 select the byte */
|
||||
u8x8_cad_SendArg(u8x8, *ptr );
|
||||
ptr++;
|
||||
}
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*==============================*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_max7219_32x8_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 100,
|
||||
/* pre_chip_disable_wait_ns = */ 100,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100,
|
||||
/* sda_setup_time_ns = */ 100,
|
||||
/* sck_pulse_width_ns = */ 100,
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150,
|
||||
/* tile_width = */ 4,
|
||||
/* tile_hight = */ 1,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 32,
|
||||
/* pixel_height = */ 8
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_max7219_32x8(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY :
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_max7219_32x8_display_info);
|
||||
return 1;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_init_seq);
|
||||
return 1;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave1_seq);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_max7219_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
/*==============================*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_max7219_16x16_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 100,
|
||||
/* pre_chip_disable_wait_ns = */ 100,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100,
|
||||
/* sda_setup_time_ns = */ 100,
|
||||
/* sck_pulse_width_ns = */ 100,
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150,
|
||||
/* tile_width = */ 2,
|
||||
/* tile_hight = */ 2,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 16,
|
||||
/* pixel_height = */ 16
|
||||
};
|
||||
|
||||
/*
|
||||
Multiple page rows are not supported, so 16x16 will not work.
|
||||
Due to the hardware structure of such displays all tiles of the display
|
||||
must be written at once.
|
||||
This is not possible with the current u8g2 structure.
|
||||
So u8x8_d_max7219_16x16 will not work.
|
||||
*/
|
||||
|
||||
uint8_t u8x8_d_max7219_16x16(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY :
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_max7219_16x16_display_info);
|
||||
return 1;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_init_seq);
|
||||
return 1;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave1_seq);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_max7219_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
/*==============================*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_max7219_8x8_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 100,
|
||||
/* pre_chip_disable_wait_ns = */ 100,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100,
|
||||
/* sda_setup_time_ns = */ 100,
|
||||
/* sck_pulse_width_ns = */ 100,
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150,
|
||||
/* tile_width = */ 1,
|
||||
/* tile_hight = */ 1,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 8,
|
||||
/* pixel_height = */ 8
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_max7219_8x8(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY :
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_max7219_8x8_display_info);
|
||||
return 1;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_init_seq);
|
||||
return 1;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave1_seq);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_max7219_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
/*==============================*/
|
||||
|
||||
static const uint8_t u8x8_d_max7219_8_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(15, 0), /* test mode off */
|
||||
U8X8_CA(15, 0), /* test mode off */
|
||||
U8X8_CA(15, 0), /* test mode off */
|
||||
U8X8_CA(15, 0), /* test mode off */
|
||||
U8X8_CA(15, 0), /* test mode off */
|
||||
U8X8_CA(15, 0), /* test mode off */
|
||||
U8X8_CA(15, 0), /* test mode off */
|
||||
U8X8_CA(15, 0), /* test mode off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(12, 0), /* */
|
||||
U8X8_CA(12, 0), /* */
|
||||
U8X8_CA(12, 0), /* */
|
||||
U8X8_CA(12, 0), /* */
|
||||
U8X8_CA(12, 0), /* */
|
||||
U8X8_CA(12, 0), /* */
|
||||
U8X8_CA(12, 0), /* */
|
||||
U8X8_CA(12, 0), /* */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(10, 10), /* medium high intensity */
|
||||
U8X8_CA(10, 10), /* medium high intensity */
|
||||
U8X8_CA(10, 10), /* medium high intensity */
|
||||
U8X8_CA(10, 10), /* medium high intensity */
|
||||
U8X8_CA(10, 10), /* medium high intensity */
|
||||
U8X8_CA(10, 10), /* medium high intensity */
|
||||
U8X8_CA(10, 10), /* medium high intensity */
|
||||
U8X8_CA(10, 10), /* medium high intensity */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
|
||||
|
||||
//U8X8_CA(12, 0), /* shutdown */
|
||||
|
||||
//U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_max7219_8_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(12, 1), /* display on */
|
||||
U8X8_CA(12, 1), /* display on */
|
||||
U8X8_CA(12, 1), /* display on */
|
||||
U8X8_CA(12, 1), /* display on */
|
||||
U8X8_CA(12, 1), /* display on */
|
||||
U8X8_CA(12, 1), /* display on */
|
||||
U8X8_CA(12, 1), /* display on */
|
||||
U8X8_CA(12, 1), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_max7219_8_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(12, 0), /* shutdown */
|
||||
U8X8_CA(12, 0), /* shutdown */
|
||||
U8X8_CA(12, 0), /* shutdown */
|
||||
U8X8_CA(12, 0), /* shutdown */
|
||||
U8X8_CA(12, 0), /* shutdown */
|
||||
U8X8_CA(12, 0), /* shutdown */
|
||||
U8X8_CA(12, 0), /* shutdown */
|
||||
U8X8_CA(12, 0), /* shutdown */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_max7219_64x8_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 100,
|
||||
/* pre_chip_disable_wait_ns = */ 100,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100,
|
||||
/* sda_setup_time_ns = */ 100,
|
||||
/* sck_pulse_width_ns = */ 100,
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150,
|
||||
/* tile_width = */ 8,
|
||||
/* tile_hight = */ 1,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 64,
|
||||
/* pixel_height = */ 8
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_max7219_64x8(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY :
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_max7219_64x8_display_info);
|
||||
return 1;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_8_init_seq);
|
||||
return 1;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_8_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_8_powersave1_seq);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_max7219_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
166
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_pcd8544_84x48.c
Normal file
166
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_pcd8544_84x48.c
Normal file
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
|
||||
u8x8_d_pcd8544_84x48.c (so called "Nokia 5110" displays)
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_pcd8544_84x48_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x021), /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
|
||||
U8X8_C(0x006), /* temp. control: b10 = 2 */
|
||||
U8X8_C(0x013), /* bias system 1:48 */
|
||||
U8X8_C(0x0c0), /* medium Vop */
|
||||
|
||||
U8X8_C(0x020), /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
U8X8_C(0x008), /* blank */
|
||||
U8X8_C(0x024), /* power down (PD=1), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_pcd8544_84x48_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x020), /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
U8X8_C(0x00c), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_pcd8544_84x48_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x020), /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
U8X8_C(0x008), /* blank */
|
||||
U8X8_C(0x024), /* power down (PD=1), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_pcd8544_84x48_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 5,
|
||||
/* pre_chip_disable_wait_ns = */ 5,
|
||||
/* reset_pulse_width_ms = */ 2,
|
||||
/* post_reset_wait_ms = */ 2,
|
||||
/* sda_setup_time_ns = */ 12,
|
||||
/* sck_pulse_width_ns = */ 75, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30,
|
||||
/* write_pulse_width_ns = */ 40,
|
||||
/* tile_width = */ 11, /* width of 11*8=88 pixel */
|
||||
/* tile_hight = */ 6,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 84,
|
||||
/* pixel_height = */ 48
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_pcd8544_84x48(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_pcd8544_84x48_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcd8544_84x48_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcd8544_84x48_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcd8544_84x48_powersave1_seq);
|
||||
break;
|
||||
// case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
// break; NOT SUPPORTED
|
||||
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x021 ); /* command mode, extended function set */
|
||||
u8x8_cad_SendCmd(u8x8, 0x080 | (arg_int >> 1) );
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x020 ); /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
u8x8_cad_SendCmd(u8x8, 0x080 | (x) ); /* set X address */
|
||||
u8x8_cad_SendCmd(u8x8, 0x040 | (((u8x8_tile_t *)arg_ptr)->y_pos) ); /* set Y address */
|
||||
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
do
|
||||
{
|
||||
if ( c + x > 84u )
|
||||
{
|
||||
if ( x >= 84u )
|
||||
break;
|
||||
c = 84u;
|
||||
c -= x;
|
||||
}
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
x += c;
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
193
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_pcf8812.c
Normal file
193
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_pcf8812.c
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
|
||||
u8x8_d_pcf8812.c
|
||||
|
||||
pcf8812: 65x102
|
||||
pcf8814: 65x96
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2017, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_pcf8812_96x65_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x020), /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
U8X8_C(0x008), /* blank display */
|
||||
|
||||
U8X8_C(0x021), /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
|
||||
U8X8_C(0x006), /* temp. control: b10 = 2 */
|
||||
U8X8_C(0x013), /* bias system, 0x010..0x07 1:48 */
|
||||
U8X8_C(0x09f), /* contrast setting, 0..127 */
|
||||
//U8X8_CA(0x020 | 2, 0x080 | 0), /* contrast setting, pcf8814 */
|
||||
|
||||
U8X8_C(0x024), /* deactivate chip (PD=1), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_pcf8812_96x65_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x020), /* power on */
|
||||
U8X8_C(0x00c), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_pcf8812_96x65_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x020), /* power on */
|
||||
U8X8_C(0x008), /* blank display */
|
||||
U8X8_C(0x024), /* power down */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8x8_d_pcf8812_96x65_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_pcf8812_96x65_display_info);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_powersave1_seq);
|
||||
break;
|
||||
/*
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
*/
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x021 ); /* command mode, extended function set */
|
||||
u8x8_cad_SendArg(u8x8, (arg_int>>1)|0x80 ); /* 0..127 for contrast */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x020 ); /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
u8x8_cad_SendCmd(u8x8, 0x080 | x);
|
||||
u8x8_cad_SendCmd(u8x8, 0x040 | ((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
/*
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 8, ptr);
|
||||
ptr += 8;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
*/
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_pcf8812_96x65_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 100,
|
||||
/* pre_chip_disable_wait_ns = */ 100,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100,
|
||||
/* sda_setup_time_ns = */ 100,
|
||||
/* sck_pulse_width_ns = */ 100,
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150,
|
||||
/* tile_width = */ 12,
|
||||
/* tile_hight = */ 9,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 96,
|
||||
/* pixel_height = */ 65
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_pcf8812_96x65(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_pcf8812_96x65_display_info);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_pcf8812_96x65_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
198
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_pcf8814_hx1230.c
Normal file
198
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_pcf8814_hx1230.c
Normal file
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
|
||||
u8x8_d_pcf8814_hc1230.c
|
||||
|
||||
pcf8814: 65x96
|
||||
hx1230: 68x96
|
||||
|
||||
pcf8814 and hc1230 are almost identical.
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2017, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_hx1230_96x68_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_C(0x020), /* power off */
|
||||
U8X8_C(0x080), /* contrast setting, 0..31, set to 0 */
|
||||
U8X8_C(0x0a6), /* not inverted display */
|
||||
U8X8_C(0x0a4), /* normal display mode */
|
||||
|
||||
U8X8_C(0x0a0), /* */
|
||||
U8X8_C(0x0c0), /* */
|
||||
|
||||
U8X8_C(0x040), /* start at scanline 0 */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_hx1230_96x68_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x02f), /* power on */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_hx1230_96x68_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_C(0x0a5), /* All pixels on = powersave */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_hx1230_96x68_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* */
|
||||
U8X8_C(0x0c0), /* */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_hx1230_96x68_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* */
|
||||
U8X8_C(0x0c8), /* */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8x8_d_hx1230_96x68_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_hx1230_96x68_display_info);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hx1230_96x68_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hx1230_96x68_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hx1230_96x68_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hx1230_96x68_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hx1230_96x68_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, (arg_int>>3)|0x80 ); /* 0..31 for contrast */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, x&15);
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | ((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const u8x8_display_info_t u8x8_hx1230_96x68_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 100,
|
||||
/* pre_chip_disable_wait_ns = */ 100,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100,
|
||||
/* sda_setup_time_ns = */ 100,
|
||||
/* sck_pulse_width_ns = */ 100,
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150,
|
||||
/* tile_width = */ 12,
|
||||
/* tile_hight = */ 9,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 96,
|
||||
/* pixel_height = */ 68
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_hx1230_96x68(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_hx1230_96x68_display_info);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_hx1230_96x68_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
227
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_s1d15721.c
Normal file
227
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_s1d15721.c
Normal file
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
|
||||
u8x8_d_s1d15721.c
|
||||
|
||||
240x64 display
|
||||
https://github.com/olikraus/u8g2/issues/1473
|
||||
http://datasheet.datasheetarchive.com/originals/library/Datasheets-ISS16/DSAIH000309343.pdf
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2020, olikraus@gmail.com
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
static const uint8_t u8x8_d_s1d15721_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0xA8), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_s1d15721_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0xA8|1), /* display off, enter sleep mode */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_s1d15721_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0xA6), /* LCD Mapping */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_s1d15721_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0xA7), /* LCD Mapping */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_s1d15721_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x += u8x8->x_offset;
|
||||
x *= 8;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0xB1); //Page Address - Row
|
||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x13); /* col */
|
||||
u8x8_cad_SendArg(u8x8, x);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x1D ); //Data Write
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
/* handled in the calling procedure
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1608_128x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15721_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15721_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15721_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15721_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*================================================*/
|
||||
/* s1d15721 240x64 */
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_s1d15721_240x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0, /* low active CS */
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 10, /* */
|
||||
/* pre_chip_disable_wait_ns = */ 20, /* */
|
||||
/* reset_pulse_width_ms = */ 1, /* */
|
||||
/* post_reset_wait_ms = */ 10,
|
||||
/* sda_setup_time_ns = */ 30, /* */
|
||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ /* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30, /* */
|
||||
/* write_pulse_width_ns = */ 65, /* */
|
||||
/* tile_width = */ 30, /* width of 20*8=160 pixel (30*8 = 240) */
|
||||
/* tile_hight = */ 8, /* height 8*8 = 64*/
|
||||
/* default_x_offset = */ 1,
|
||||
/* flipmode_x_offset = */ 1,
|
||||
/* pixel_width = */ 240,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_s1d15721_240x64_init_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0xC4|1), /* (5) Common Output Status (Reverse) */
|
||||
U8X8_CA(0xA6, 0x01), /* (3) Display Normal Reverse (Normal) */
|
||||
U8X8_CA(0xA4, 0x00), /* (4) Display All Light (Normal) */
|
||||
U8X8_CAA(0x6D,0x10,0x02), /* (18) Duty Set Command */
|
||||
U8X8_CA(0x66, 0x01), /* (15) Display Mode, Parameter 0 (0 = Gray Scale 1 = Binary */
|
||||
U8X8_CA(0x39, 0x36), /* (16) Gray Scale Pattern Set, Pattern */
|
||||
U8X8_CA(0x2B, 0x07), /* (27) LCD Drive Mode Voltage Select, Parameter */
|
||||
U8X8_CA(0x81, 0x0a), /* (28) Electronic Volume, Parameter */
|
||||
U8X8_CA(0x5F, 0x00), /* (24) Built-in Oscillator Frequency, Parameter */
|
||||
U8X8_C(0xAA|1), /* (23) Built-in OSC On */
|
||||
U8X8_CA(0x25, 0x1f), /* (25) Power Control Set, Parameter */
|
||||
U8X8_CA(0x8A, 0x00), /* (6) Start Line Setup, Parameter */
|
||||
U8X8_CA(0xB1, 0x00), /* (7) Page Address Set, Parameter */
|
||||
U8X8_CA(0x13, 0x00), /* (8) Column Address Set */
|
||||
U8X8_C(0xAE|1), /* (1) Display ON/OFF */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_s1d15721_240x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
/* checking for the flip mode cmd first */
|
||||
if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE )
|
||||
{
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15721_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15721_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/* call the common procedure, this now leads to the effect, that the flip code is executed again */
|
||||
/* maybe we should paste the common code here to avoid this */
|
||||
|
||||
|
||||
if ( u8x8_d_s1d15721_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_s1d15721_240x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15721_240x64_init_seq);
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
250
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_s1d15e06.c
Normal file
250
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_s1d15e06.c
Normal file
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
|
||||
u8x8_d_s1d15e06.c
|
||||
|
||||
https://github.com/olikraus/u8g2/pull/1190
|
||||
https://github.com/olikraus/u8g2/issues/1172
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2020, olikraus@gmail.com
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
static const uint8_t u8x8_d_s1d15e06_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0xA8), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_s1d15e06_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0xA8|1), /* display off, enter sleep mode */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_s1d15e06_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0xA6), /* LCD Mapping */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_s1d15e06_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0xA7), /* LCD Mapping */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_s1d15e06_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0xB1); //Page Address - Row
|
||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
||||
y += u8x8->x_offset;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x13); /* col */
|
||||
u8x8_cad_SendArg(u8x8, x);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x1D ); //Data Write
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
/* handled in the calling procedure
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1608_128x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15e06_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15e06_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15e06_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15e06_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*================================================*/
|
||||
/* s1d15e06 160x100 */
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_s1d15e06_160100_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0, /* s1d15e06 has low active CS */
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 10, /* uc1608 datasheet, page 39, actually 0 */
|
||||
/* pre_chip_disable_wait_ns = */ 20, /* uc1608 datasheet, page 39 */
|
||||
/* reset_pulse_width_ms = */ 1, /* uc1608 datasheet, page 42 */
|
||||
/* post_reset_wait_ms = */ 10,
|
||||
/* sda_setup_time_ns = */ 30, /* uc1608 datasheet, page 41 */
|
||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30, /* uc1608 datasheet, page 39 */
|
||||
/* write_pulse_width_ns = */ 65, /* uc1608 datasheet, page 39 */
|
||||
/* tile_width = */ 20, /* width of 20*8=160 pixel */
|
||||
/* tile_hight = */ 13,
|
||||
/* default_x_offset = */ 0, /* reused as y page offset */
|
||||
/* flipmode_x_offset = */ 0, /* reused as y page offset */
|
||||
/* pixel_width = */ 160,
|
||||
/* pixel_height = */ 100
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_s1d15e06_160100_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
/* (Command no in datasheet) Description */
|
||||
U8X8_C(0xA0|1), /* (12) Column Address Direction (Reverse) */
|
||||
|
||||
U8X8_C(0xC4|1), /* (5) Common Output Status (Reverse) */
|
||||
U8X8_C(0x84), /* (11) Display Data In. Direction (Normal) */
|
||||
|
||||
U8X8_C(0xA6), /* (3) Display Normal Reverse (Normal) */
|
||||
U8X8_C(0xA4), /* (4) Display All Light (Normal) */
|
||||
|
||||
|
||||
U8X8_CAA(0x6D,0x18,0x04), /* (18) Duty Set Command,
|
||||
Parameter "Duty Set" 1/96 ,
|
||||
Parameter "Start Point Set" */
|
||||
|
||||
U8X8_CA(0x66, 0x01), /* (15) Display Mode, Parameter 0 (4 Gray Scale) 1 (Binary) */
|
||||
U8X8_CA(0x39, 0x43), /* (16) Gray Scale Pattern Set, Pattern */
|
||||
U8X8_C(0xBE|1), /* (2) Display Off Mode (0 VSS / 1 Vcc) */
|
||||
|
||||
U8X8_CA(0x2B, 0x03), /* (27) LCD Drive Mode Voltage Select, Parameter */
|
||||
|
||||
U8X8_CA(0x81, 0x32), /* (28) Electronic Volume, Parameter */
|
||||
U8X8_C(0xE4|1), /* (14) N-Line On Off (On) */
|
||||
U8X8_CA(0x36, 0x05), /* (13) N-Line Inversion Drive, Parameter (6x4) */
|
||||
|
||||
U8X8_CA(0x41, 0x03), /* (13) (26) Step-up CK Frequency Select, fosc/8 */
|
||||
U8X8_CA(0x5F, 0x04), /* (24) Built-in Oscillator Frequency, Parameter */
|
||||
U8X8_C(0xAA|1), /* (23) Built-in OSC On */
|
||||
|
||||
U8X8_CA(0x25, 0x1F), /* (25) Power Control Set, Parameter */
|
||||
|
||||
U8X8_CA(0x8A, 0x00), /* (6) Start Line Setup, Parameter */
|
||||
U8X8_CA(0xB1, 0x00), /* (7) Page Address Set, Parameter */
|
||||
U8X8_CA(0x13, 0x00), /* (8) Column Address Set */
|
||||
|
||||
U8X8_C(0xAE|1), /* (1) Display ON/OFF */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_s1d15e06_160100(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
/* checking for the flip mode cmd first */
|
||||
if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE )
|
||||
{
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15e06_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15e06_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/* call the common procedure, this now leads to the effect, that the flip code is executed again */
|
||||
/* maybe we should paste the common code here to avoid this */
|
||||
|
||||
|
||||
if ( u8x8_d_s1d15e06_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_s1d15e06_160100_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15e06_160100_init_seq);
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
217
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_sbn1661.c
Normal file
217
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_sbn1661.c
Normal file
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
|
||||
u8x8_d_sbn1661.c
|
||||
|
||||
SED1520 / SBN1661 122x32 5V LCD
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_sbn1661_init_seq[] = {
|
||||
U8X8_C(0x0c0), /* display start at line 0 */
|
||||
U8X8_C(0x0a0), /* a0: ADC forward, a1: ADC reverse */
|
||||
U8X8_C(0x0a4), /* a4: normal driving, a5: power save */
|
||||
U8X8_C(0x0a9), /* a8: 1/16, a9: 1/32 duty */
|
||||
|
||||
//U8X8_C(0x0af), /* display on */
|
||||
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sbn1661_powersave0_seq[] = {
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sbn1661_powersave1_seq[] = {
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
struct u8x8_sbn1661_vars
|
||||
{
|
||||
uint8_t *ptr;
|
||||
uint8_t x;
|
||||
uint8_t c;
|
||||
uint8_t arg_int;
|
||||
};
|
||||
|
||||
#ifdef NOT_USED
|
||||
static void u8x8_sbn1661_out(u8x8_t *u8x8, struct u8x8_sbn1661_vars *v, void *arg_ptr)
|
||||
{
|
||||
uint8_t cnt;
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((v->x << 3) & 63) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b8 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
while( v->arg_int > 0 )
|
||||
{
|
||||
/* calculate tiles to next boundary (end or chip limit) */
|
||||
cnt = v->x;
|
||||
cnt += 8;
|
||||
cnt &= 0x0f8;
|
||||
cnt -= v->x;
|
||||
|
||||
if ( cnt > v->c )
|
||||
cnt = v->c;
|
||||
|
||||
/* of course we still could use cnt=1 here... */
|
||||
/* but setting cnt to 1 is not very efficient */
|
||||
//cnt = 1;
|
||||
|
||||
v->x +=cnt;
|
||||
v->c-=cnt;
|
||||
cnt<<=3;
|
||||
u8x8_cad_SendData(u8x8, cnt, v->ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
v->ptr += cnt;
|
||||
|
||||
if ( v->c == 0 )
|
||||
{
|
||||
v->ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
v->c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
v->arg_int--;
|
||||
}
|
||||
if ( ((v->x) & 7) == 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* NOT_USED */
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_sbn1661_122x32_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0, /* sbn1661: Not used */
|
||||
/* chip_disable_level = */ 1, /* sbn1661: Not used */
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 100,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6, /* */
|
||||
/* sda_setup_time_ns = */ 12,
|
||||
/* sck_pulse_width_ns = */ 75, /* sbn1661: Not used */
|
||||
/* sck_clock_hz = */ 4000000UL, /* sbn1661: Not used */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4, /* sbn1661: Not used */
|
||||
/* data_setup_time_ns = */ 200,
|
||||
/* write_pulse_width_ns = */ 200, /* */
|
||||
/* tile_width = */ 16, /* width of 16*8=128 pixel */
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 122,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_sbn1661_122x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t *ptr;
|
||||
//uint8_t x;
|
||||
//uint8_t c;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sbn1661_122x32_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_init_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_init_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 1, NULL);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_powersave0_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_powersave0_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 1, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_powersave1_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_powersave1_seq);
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 1, NULL);
|
||||
|
||||
}
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
// x and c are ignored (u8g2 only)
|
||||
//x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
//c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | 0); // column 0
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b8 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
u8x8_cad_SendData(u8x8, 61, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
||||
|
||||
ptr += 61;
|
||||
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | 0); // column 0
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b8 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
u8x8_cad_SendData(u8x8, 61, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 1, NULL);
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8x8_d_sed1520_122x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
return u8x8_d_sbn1661_122x32(u8x8, msg, arg_int, arg_ptr);
|
||||
|
||||
}
|
||||
351
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_sed1330.c
Normal file
351
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_sed1330.c
Normal file
@@ -0,0 +1,351 @@
|
||||
/*
|
||||
|
||||
u8x8_d_sed1330.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
The device might also work with the RA8835, SED1335 and SED1336 controller.
|
||||
The following devices might be compatible:
|
||||
RA8835
|
||||
SED1330
|
||||
SED1335
|
||||
S1D13700
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_sed1330_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */
|
||||
U8X8_CA(0x059, 0x004), /* send display on command (hex 0x059, see p37 ) */
|
||||
/* display cmd has one arg: 01010100 should enable all three blocks, but disable the cursor*/
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sed1330_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x058, 0x000), /* send display off command (hex 0x059, see p37) and turn of all banks */
|
||||
/* maybe send a sleep in cmd */
|
||||
//U8X8_C(0x053) /* sleep in: 0x053 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_sed1330_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t c, i;
|
||||
uint16_t y;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* U8X8_MSG_DISPLAY_SETUP_MEMORY is handled by the calling function */
|
||||
/*
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
y*=8;
|
||||
y*= u8x8->display_info->tile_width;
|
||||
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
u8x8_cad_SendCmd(u8x8, 0x046 ); /* CSRW command*/
|
||||
u8x8_cad_SendArg(u8x8, y&255); /* CSRW low adr byte */
|
||||
u8x8_cad_SendArg(u8x8, y>>8); /* CSRW high adr byte */
|
||||
u8x8_cad_SendCmd(u8x8, 0x042 ); /* MWRITE */
|
||||
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes, send one line of data */
|
||||
|
||||
ptr += u8x8->display_info->tile_width;
|
||||
y += u8x8->display_info->tile_width;
|
||||
}
|
||||
|
||||
/* sometimes the display switches off... so just sent a display on command */
|
||||
u8x8_cad_SendCmd(u8x8, 0x059 ); /* display on */
|
||||
u8x8_cad_SendArg(u8x8, 0x004); /* arg for display on */
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
//u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*=============================================*/
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_sed1330_240x128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 30, /* G242CX Datasheet p5 */
|
||||
/* pre_chip_disable_wait_ns = */ 10, /* G242CX Datasheet p5 */
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 20,
|
||||
/* sck_pulse_width_ns = */ 140,
|
||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0,
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 120, /* G242CX Datasheet p5 */
|
||||
/* write_pulse_width_ns = */ 220, /* G242CX Datasheet p5 */
|
||||
/* tile_width = */ 0x01e,
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 240,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
/* 240x128 Seiko G242C */
|
||||
static const uint8_t u8x8_d_sed1330_240x128_init_seq[] = {
|
||||
U8X8_DLY(100),
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(100),
|
||||
|
||||
/* system init command, see also u8x8_d_sed1330_powersave0_seq */
|
||||
U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */
|
||||
/* system init has total 8 parameters, so 7 more are here */
|
||||
U8X8_A(0x087), /* no idea here... WF (topmost bit) is set to one because it is suggested in the datasheet, lowest 3 bits refer to text mode only */
|
||||
U8X8_A(0x007), /* FY: height of a char+1, does not matter here (hopefully), because we use graphics mode only */
|
||||
U8X8_A(0x01d), /* C/R: this could be the number of horizontal bytes - 1 (Value confirmed with app notes p41) */
|
||||
U8X8_A(0x050), /* TC/R: According to app notes fOSC=6Mhz fFF=70Hz --> TC/R = 74d*/
|
||||
U8X8_A(0x080), /* L/F: Lines per frame - 1, probably this is the height of the display - 1 (value confirmed with app notes p41)*/
|
||||
U8X8_A(0x01e), /* Low byte of the virtual screen size. (Value confirmed with app notes p41) */
|
||||
U8X8_A(0), /* High byte of the virtual screen size, see also section 9.1.2 */
|
||||
|
||||
U8X8_C(0x044), /* SCROLL */
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x080),
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x040),
|
||||
U8X8_A(0x080),
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x000),
|
||||
|
||||
U8X8_CA(0x05a, 0), /* HDOT SCR: Horizontal dotwise scroll... set to 0 */
|
||||
|
||||
U8X8_CA(0x05b, 0x0c), /* OVLAY: 2-layer, all graphics, OR between layer 1 and 2 */
|
||||
|
||||
|
||||
U8X8_DLY(100),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_DLY(100),
|
||||
};
|
||||
|
||||
/* RA8835 NHD-240128BZ */
|
||||
static const uint8_t u8x8_d_rh8835_nhd_240128_init_seq[] = {
|
||||
U8X8_DLY(100),
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(100),
|
||||
|
||||
/* system init command, see also u8x8_d_sed1330_powersave0_seq */
|
||||
U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */
|
||||
/* system init has total 8 parameters, so 7 more are here */
|
||||
U8X8_A(0x087), /* no idea here... WF (topmost bit) is set to one because it is suggested in the datasheet, lowest 3 bits refer to text mode only */
|
||||
U8X8_A(0x007), /* FY: height of a char+1, does not matter here (hopefully), because we use graphics mode only */
|
||||
U8X8_A(0x01d), /* C/R: this could be the number of horizontal bytes - 1 (Value confirmed with app notes p41) */
|
||||
U8X8_A(0x050), /* TC/R: According to app notes fOSC=6Mhz fFF=70Hz --> TC/R = 74d*/
|
||||
U8X8_A(0x080), /* L/F: Lines per frame - 1, probably this is the height of the display - 1 (value confirmed with app notes p41)*/
|
||||
U8X8_A(0x01e), /* Low byte of the virtual screen size. (Value confirmed with app notes p41) */
|
||||
U8X8_A(0), /* High byte of the virtual screen size, see also section 9.1.2 */
|
||||
|
||||
U8X8_C(0x044), /* SCROLL */
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x080),
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x040),
|
||||
U8X8_A(0x080),
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x000),
|
||||
|
||||
//U8X8_CA(0x05a, 0), /* HDOT SCR: Horizontal dotwise scroll... set to 0 */
|
||||
|
||||
U8X8_CA(0x05b, 0x0c), /* OVLAY: 2-layer, all graphics, OR between layer 1 and 2 */
|
||||
|
||||
//U8X8_CA(0x059, 0x04), /* send display on command (hex 0x059, see p37 ) */
|
||||
|
||||
U8X8_DLY(100),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_DLY(100),
|
||||
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_sed1330_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sed1330_240x128_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_240x128_init_seq);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_sed1330_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8x8_d_ra8835_nhd_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sed1330_240x128_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_rh8835_nhd_240128_init_seq);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_sed1330_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*=============================================*/
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_sed1330_320x240_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 30, /* G242CX Datasheet p5 */
|
||||
/* pre_chip_disable_wait_ns = */ 10, /* G242CX Datasheet p5 */
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 20,
|
||||
/* sck_pulse_width_ns = */ 140,
|
||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0,
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 120, /* G242CX Datasheet p5 */
|
||||
/* write_pulse_width_ns = */ 220, /* G242CX Datasheet p5 */
|
||||
/* tile_width = */ 40,
|
||||
/* tile_hight = */ 30,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 320,
|
||||
/* pixel_height = */ 240
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sed1330_320x240_init_seq[] = {
|
||||
U8X8_DLY(100),
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(100),
|
||||
|
||||
/* system init command, see also u8x8_d_sed1330_powersave0_seq */
|
||||
U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */
|
||||
/* system init has total 8 parameters, so 7 more are here */
|
||||
U8X8_A(0x087), /* no idea here... WF (topmost bit) is set to one because it is suggested in the datasheet, lowest 3 bits refer to text mode only */
|
||||
U8X8_A(0x007), /* FY: height of a char+1, does not matter here (hopefully), because we use graphics mode only */
|
||||
U8X8_A(0x027), /* 40-1 */ /* C/R: this could be the number of horizontal bytes - 1 (Value confirmed with app notes p41) */
|
||||
U8X8_A(0x039), /* TC/R: According to app notes fOSC=6Mhz fFF=70Hz --> TC/R = 74d*/
|
||||
U8X8_A(0x0ef), /* L/F: Lines per frame - 1, probably this is the height of the display - 1 (value confirmed with app notes p41)*/
|
||||
U8X8_A(0x028), /* Low byte of the virtual screen size. (Value confirmed with app notes p41) */
|
||||
U8X8_A(0), /* High byte of the virtual screen size, see also section 9.1.2 */
|
||||
|
||||
U8X8_C(0x044), /* SCROLL */
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x0ef),
|
||||
U8X8_A(0x0b0),
|
||||
U8X8_A(0x004),
|
||||
U8X8_A(0x0ef),
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x000),
|
||||
|
||||
U8X8_CA(0x05a, 0), /* HDOT SCR: Horizontal dotwise scroll... set to 0 */
|
||||
|
||||
U8X8_CA(0x05b, 0x0c), /* OVLAY: 2-layer, all graphics, OR between layer 1 and 2 */
|
||||
|
||||
|
||||
U8X8_DLY(100),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_DLY(100),
|
||||
};
|
||||
|
||||
|
||||
|
||||
uint8_t u8x8_d_ra8835_320x240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sed1330_320x240_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_320x240_init_seq);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_sed1330_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
215
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_sh1106_64x32.c
Normal file
215
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_sh1106_64x32.c
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
|
||||
u8x8_d_sh1106_64x32.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2018, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
/* issue 568 */
|
||||
static const uint8_t u8x8_d_sh1106_64x32_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0a8, 0x01f), /* multiplex ratio, 0.42 OLED */
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset, 0.42 OLED */
|
||||
U8X8_C(0x040), /* set display start line to 0, 0.42 OLED */
|
||||
U8X8_CA(0xad, 0x8b), /* DC-DC ON/OFF Mode Set: Built-in DC-DC is used, Normal Display (POR = 0x8b) */
|
||||
U8X8_C(0x33), /* set charge pump voltage 0x30 (POR) .. 0x33 */
|
||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1, 0.66 OLED */
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse, 0.66 OLED */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), 0.66 OLED */
|
||||
U8X8_CA(0x081, 0x080), /* [2] set contrast control, 0.42 OLED datasheet: 0xcf */
|
||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1, 0.42 OLED datasheet: 0x22 */
|
||||
U8X8_CA(0x0db, 0x028), /* vcomh deselect level, 0.42 OLED datasheet: 0x00 */
|
||||
|
||||
U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sh1106_64x32_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sh1106_64x32_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sh1106_64x32_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_CA(0x0d3, 0), /* display offset, 0.42 OLED */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sh1106_64x32_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_CA(0x0d3, 0), /* What is the correct offset in flip 1 mode? --> Issue 547 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8x8_d_sh1106_64x32_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1106_64x32_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_64x32_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_64x32_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_64x32_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_64x32_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_64x32_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* copied from SSD1306 */
|
||||
static const u8x8_display_info_t u8x8_sh1106_64x32_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 8,
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 32,
|
||||
/* flipmode_x_offset = */ 36,
|
||||
/* pixel_width = */ 64,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_sh1106_64x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1106_64x32_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_64x32_init_seq);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_sh1106_64x32_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
216
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_sh1106_72x40.c
Normal file
216
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_sh1106_72x40.c
Normal file
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
|
||||
u8x8_d_sh1106_72x40.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2018, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
/* WiseChip 0.42 OLED, issue 547 */
|
||||
static const uint8_t u8x8_d_sh1106_72x40_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0a8, 0x027), /* multiplex ratio, 0.42 OLED */
|
||||
U8X8_CA(0x0d3, 0x00c), /* display offset, 0.42 OLED */
|
||||
U8X8_C(0x040), /* set display start line to 0, 0.42 OLED */
|
||||
U8X8_CA(0xad, 0x8b), /* DC-DC ON/OFF Mode Set: Built-in DC-DC is used, Normal Display (POR = 0x8b) */
|
||||
U8X8_C(0x33), /* set charge pump voltage 0x30 (POR) .. 0x33 */
|
||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1, 0.66 OLED */
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse, 0.66 OLED */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), 0.66 OLED */
|
||||
U8X8_CA(0x081, 0x080), /* [2] set contrast control, 0.42 OLED datasheet: 0xcf */
|
||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1, 0.42 OLED datasheet: 0x22 */
|
||||
U8X8_CA(0x0db, 0x028), /* vcomh deselect level, 0.42 OLED datasheet: 0x00 */
|
||||
|
||||
U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sh1106_72x40_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sh1106_72x40_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sh1106_72x40_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_CA(0x0d3, 12), /* display offset, 0.42 OLED */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sh1106_72x40_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_CA(0x0d3, 52), /* What is the correct offset in flip 1 mode? --> Issue 547 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8x8_d_sh1106_72x40_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1106_72x40_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_72x40_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_72x40_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_72x40_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_72x40_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_72x40_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* copied from SSD1306 */
|
||||
static const u8x8_display_info_t u8x8_sh1106_72x40_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 9,
|
||||
/* tile_hight = */ 5,
|
||||
/* default_x_offset = */ 30,
|
||||
/* flipmode_x_offset = */ 30,
|
||||
/* pixel_width = */ 72,
|
||||
/* pixel_height = */ 40
|
||||
};
|
||||
|
||||
/* WiseChip 0.42" OLED */
|
||||
uint8_t u8x8_d_sh1106_72x40_wise(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1106_72x40_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_72x40_init_seq);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_sh1106_72x40_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
552
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_sh1107.c
Normal file
552
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_sh1107.c
Normal file
@@ -0,0 +1,552 @@
|
||||
/*
|
||||
|
||||
u8x8_d_sh1107.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2017, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
/* code copyied from SSD1306 */
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_sh1107_64x128_noname_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sh1107_64x128_noname_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sh1107_64x128_noname_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sh1107_64x128_noname_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8x8_d_sh1107_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_64x128_noname_display_info);
|
||||
break;
|
||||
*/
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* sh1107 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
//u8x8_cad_SendCmd(u8x8, 0x040 ); /* set line offset to 0 */
|
||||
|
||||
// set column address
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4));
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x & 15))); /* probably wrong, should be SendCmd */
|
||||
|
||||
// set page address
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos)); /* probably wrong, should be SendCmd */
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
/*
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 8, ptr);
|
||||
ptr += 8;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
*/
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*==================================================*/
|
||||
|
||||
/* QG-6428TSWKG01 */
|
||||
static const uint8_t u8x8_d_sh1107_64x128_noname_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0dc, 0x000), /* start line */
|
||||
U8X8_CA(0x081, 0x02f), /* [2] set contrast control */
|
||||
U8X8_C(0x020), /* addressing mode */
|
||||
|
||||
// U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
// Flipmode
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0a8, 0x7f), /* 0x03f) multiplex ratio */
|
||||
U8X8_CA(0x0d3, 0x060), /* display offset */
|
||||
U8X8_CA(0x0d5, 0x051), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1*/
|
||||
U8X8_CA(0x0db, 0x035), /* vcomh deselect level */
|
||||
|
||||
U8X8_C(0x0b0), /* set page address */
|
||||
U8X8_CA(0x0da, 0x012), /* set com pins */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const u8x8_display_info_t u8x8_sh1107_64x128_noname_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* sh1107: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* sh1107: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* sh1107: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 8,
|
||||
/* tile_height = */ 16,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 64,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_sh1107_64x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_64x128_noname_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*==================================================*/
|
||||
|
||||
/* init sequence from Grove OLED 96x96 */
|
||||
static const uint8_t u8x8_d_sh1107_seeed_96x96_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x050), /* clock divide ratio (0x00=1) and oscillator frequency (0x5) */
|
||||
U8X8_C(0x020), /* use page addressing mode */
|
||||
//U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
||||
U8X8_CA(0x0dc, 0x000), /* start line */
|
||||
//U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
//U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
|
||||
U8X8_CA(0x081, 0x080), /* [2] set contrast control */
|
||||
U8X8_CA(0x0ad, 0x080), /* */
|
||||
U8X8_CA(0x0d9, 0x01f), /* [2] pre-charge period 0x022/f1*/
|
||||
U8X8_CA(0x0db, 0x027), /* vcomh deselect level */
|
||||
// if vcomh is 0, then this will give the biggest range for contrast control issue #98
|
||||
// restored the old values for the noname constructor, because vcomh=0 will not work for all OLEDs, #116
|
||||
|
||||
//U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const u8x8_display_info_t u8x8_sh1107_seeed_96x96_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 100, /* cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 100, /* cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 12,
|
||||
/* tile_hight = */ 12,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 96,
|
||||
/* pixel_height = */ 96
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_sh1107_seeed_96x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_seeed_96x96_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_seeed_96x96_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*==================================================*/
|
||||
/* 128x128 OLED: this display has a very strange x offset */
|
||||
|
||||
/* sequence taken over from 64x128 sequence, because it seems to work mostly */
|
||||
static const uint8_t u8x8_d_sh1107_128x128_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0dc, 0x000), /* start line */
|
||||
U8X8_CA(0x081, 0x02f), /* [2] set contrast control */
|
||||
U8X8_C(0x020), /* use page addressing mode */
|
||||
|
||||
// U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
// Flipmode
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0a8, 0x7f), /* 0x03f multiplex ratio */
|
||||
//U8X8_CA(0x0d3, 0x060), /* display offset (removed, not in datasheet ) */
|
||||
U8X8_CA(0x0d5, 0x050), /* clock divide ratio (0x00=1) and oscillator frequency (0x8), changed to 0x051, issue 501 */
|
||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1*/
|
||||
U8X8_CA(0x0db, 0x035), /* vcomh deselect level */
|
||||
|
||||
U8X8_C(0x0b0), /* set page address */
|
||||
U8X8_CA(0x0da, 0x012), /* set com pins */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_sh1107_128x128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 100, /* cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 100, /* cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 96,
|
||||
/* flipmode_x_offset = */ 96,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_sh1107_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_128x128_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_128x128_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*==================================================*/
|
||||
/* 128x80 OLED, copyied from SEEED 128x128 oled, this display has a very strange x offset */
|
||||
/* https://github.com/olikraus/u8g2/issues/1598 */
|
||||
/* this is actually a 80x128 display, but let's keep the 128x80 name */
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_sh1107_128x80_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 100, /* cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 100, /* cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 10,
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 24,
|
||||
/* flipmode_x_offset = */ 24,
|
||||
/* pixel_width = */ 80,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_sh1107_128x80(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_128x128_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_128x80_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*==================================================*/
|
||||
/* pimoroni_128x128_display */
|
||||
|
||||
static const u8x8_display_info_t u8x8_sh1107_pimoroni_128x128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 100, /* cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 100, /* cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_sh1107_pimoroni_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_128x128_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_pimoroni_128x128_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*==================================================*/
|
||||
/*
|
||||
Name: SH1107_seeed_128x128
|
||||
URL: https://www.seeedstudio.com/Grove-OLED-Display-1-12-V2.html
|
||||
Display is there in my lab. Backside PCB label: "OLED Display 1.12 inch v1.0"
|
||||
Tookover code from SSD1327_SEEED_96X96 because none of the other displays did work
|
||||
and at least the 96x96 driver did show something.
|
||||
*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_seeed_128x128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 100, /* cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 100, /* cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 2, // 400kHz does not work, but 200kHz seems to be ok
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_sh1107_seeed_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_128x128_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_seeed_128x128_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
225
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_sh1108.c
Normal file
225
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_sh1108.c
Normal file
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
|
||||
u8x8_d_sh1108.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2018, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
/*
|
||||
code copyied from sh1107
|
||||
SH1108: 160x160 controller from Sino Wealth
|
||||
*/
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_sh1108_noname_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sh1108_noname_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sh1108_160x160_noname_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sh1108_160x160_noname_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8x8_d_sh1108_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1108_64x128_noname_display_info);
|
||||
break;
|
||||
*/
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1108_64x128_noname_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1108_noname_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1108_noname_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1108_160x160_noname_powersave0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1108_160x160_noname_powersave1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* sh1108 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
//u8x8_cad_SendCmd(u8x8, 0x040 ); /* set line offset to 0 */
|
||||
|
||||
// set column address
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4));
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x & 15)));
|
||||
|
||||
// set page address
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 ); // page cmd is a two byte command
|
||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*==================================================*/
|
||||
|
||||
/* issue #619, 160x160 OLED */
|
||||
static const uint8_t u8x8_d_sh1108_160x160_noname_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x060), /* clock divide ratio and oscillator frequency */
|
||||
U8X8_CA(0x0a9, 0x003), /* set display resolution, 0=64x160, 1=96x160, 2=128x160, 3=160x160 */
|
||||
U8X8_C(0x020), /* addressing mode */
|
||||
U8X8_CA(0x081, 0x01f), /* set contrast control */
|
||||
U8X8_CA(0x0ad, 0x80), /* DC/DC control 80=Use external Vpp, 89=Use internal DC/DC*/
|
||||
U8X8_C(0x030), /* set discharge VSL level, 0x030..0x03f */
|
||||
U8X8_CA(0x0d9, 0x028), /* pre-charge period */
|
||||
U8X8_CA(0x0db, 0x035), /* vcomh deselect level */
|
||||
U8X8_CA(0x0dc, 0x035), /* VSEGM Deselect Level */
|
||||
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const u8x8_display_info_t u8x8_sh1108_160x160_noname_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 60,
|
||||
/* pre_chip_disable_wait_ns = */ 120,
|
||||
/* reset_pulse_width_ms = */ 100, /* sh1108: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* sometimes OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 100, /* sh1108: 100ns */
|
||||
/* sck_pulse_width_ns = */ 100, /* sh1108: 100ns */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* sh1108: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 20,
|
||||
/* tile_height = */ 20,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 160,
|
||||
/* pixel_height = */ 160
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_sh1108_160x160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_sh1108_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1108_160x160_noname_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1108_160x160_noname_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*==================================================*/
|
||||
287
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_sh1122.c
Normal file
287
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_sh1122.c
Normal file
@@ -0,0 +1,287 @@
|
||||
/*
|
||||
|
||||
u8x8_d_sh1122.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
Copied from sh1122 mostly because of the similar RAM architecture.
|
||||
However: Commands are very different!
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_sh1122_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* sh1122: display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sh1122_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* sh1122: display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
input:
|
||||
one tile (8 Bytes)
|
||||
output:
|
||||
Tile for SH1122 (32 Bytes)
|
||||
*/
|
||||
|
||||
/*
|
||||
static uint8_t u8x8_sh1122_to32_dest_buf[32];
|
||||
|
||||
static uint8_t *u8x8_sh1122_8to32(U8X8_UNUSED u8x8_t *u8x8, uint8_t *ptr)
|
||||
{
|
||||
uint8_t v;
|
||||
uint8_t a,b;
|
||||
uint8_t i, j;
|
||||
uint8_t *dest;
|
||||
|
||||
for( j = 0; j < 4; j++ )
|
||||
{
|
||||
dest = u8x8_sh1122_to32_dest_buf;
|
||||
dest += j;
|
||||
a =*ptr;
|
||||
ptr++;
|
||||
b = *ptr;
|
||||
ptr++;
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
v = 0;
|
||||
if ( a&1 ) v |= 0xf0;
|
||||
if ( b&1 ) v |= 0x0f;
|
||||
*dest = v;
|
||||
dest+=4;
|
||||
a >>= 1;
|
||||
b >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return u8x8_sh1122_to32_dest_buf;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
static uint8_t u8x8_write_byte_to_16gr_device(u8x8_t *u8x8, uint8_t b)
|
||||
{
|
||||
static uint8_t buf[4];
|
||||
static uint8_t map[4] = { 0, 0x00f, 0x0f0, 0x0ff };
|
||||
buf [3] = map[b & 3];
|
||||
b>>=2;
|
||||
buf [2] = map[b & 3];
|
||||
b>>=2;
|
||||
buf [1] = map[b & 3];
|
||||
b>>=2;
|
||||
buf [0] = map[b & 3];
|
||||
return u8x8_cad_SendData(u8x8, 4, buf);
|
||||
}
|
||||
|
||||
uint8_t u8x8_d_sh1122_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x;
|
||||
uint8_t y, c, i;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* U8X8_MSG_DISPLAY_SETUP_MEMORY is handled by the calling function */
|
||||
/*
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1122_256x64_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1122_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1122_powersave1_seq);
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* sh1122 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 2; // only every 4th col can be addressed
|
||||
x += u8x8->x_offset;
|
||||
|
||||
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
y *= 8;
|
||||
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 ); /* set row address */
|
||||
u8x8_cad_SendArg(u8x8, y);
|
||||
u8x8_cad_SendCmd(u8x8, x & 15 ); /* lower 4 bit*/
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4) ); /* higher 3 bit */
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
||||
|
||||
while ( c > 0 )
|
||||
{
|
||||
u8x8_write_byte_to_16gr_device(u8x8, *ptr);
|
||||
c--;
|
||||
ptr++;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*=========================================================*/
|
||||
|
||||
static const uint8_t u8x8_d_sh1122_256x64_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* remap */
|
||||
U8X8_C(0x0c8), /* remap */
|
||||
U8X8_C(0x060),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_sh1122_256x64_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* remap */
|
||||
U8X8_C(0x0c0), /* remap */
|
||||
U8X8_C(0x040),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const u8x8_display_info_t u8x8_sh1122_256x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 10, /* sh1122: 10 us */
|
||||
/* post_reset_wait_ms = */ 20, /* */
|
||||
/* sda_setup_time_ns = */ 125, /* sh1122: cycle time is 250ns, so use 250/2 */
|
||||
/* sck_pulse_width_ns = */ 125, /* sh1122: cycle time is 250ns, so use 250/2 */
|
||||
/* sck_clock_hz = */ 40000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 10,
|
||||
/* write_pulse_width_ns = */ 150, /* sh1122: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 32, /* 256 pixel, so we require 32 bytes for this */
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0, /* this is the byte offset (there are two pixel per byte with 4 bit per pixel) */
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 256,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_sh1122_256x64_init_seq[] = {
|
||||
|
||||
U8X8_DLY(1),
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(1),
|
||||
|
||||
U8X8_C(0xae), /* display off */
|
||||
U8X8_C(0x40), /* display start line */
|
||||
U8X8_C(0x0a0), /* remap */
|
||||
U8X8_C(0x0c0), /* remap */
|
||||
U8X8_CA(0x81, 0x80), /* set display contrast */
|
||||
U8X8_CA(0xa8, 0x3f), /* multiplex ratio 1/64 Duty (0x0F~0x3F) */
|
||||
U8X8_CA(0xad, 0x81), /* use buildin DC-DC with 0.6 * 500 kHz */
|
||||
|
||||
U8X8_CA(0xd5, 0x50), /* set display clock divide ratio (lower 4 bit)/oscillator frequency (upper 4 bit) */
|
||||
U8X8_CA(0xd3, 0x00), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0xd9, 0x22), /* pre charge (lower 4 bit) and discharge(higher 4 bit) period */
|
||||
U8X8_CA(0xdb, 0x35), /* VCOM deselect level */
|
||||
U8X8_CA(0xdc, 0x35), /* Pre Charge output voltage */
|
||||
U8X8_C(0x030), /* discharge level */
|
||||
|
||||
U8X8_DLY(1), /* delay */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_sh1122_256x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1122_256x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1122_256x64_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1122_256x64_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1122_256x64_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return u8x8_d_sh1122_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
450
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1305.c
Normal file
450
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1305.c
Normal file
@@ -0,0 +1,450 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1305.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2017, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1305_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1305_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1305_128x32_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0d3, 32), /* display offset to 32 */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1305_128x32_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0d3, 0), /* display offset to */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1305_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x040 ); /* set line offset to 0 */
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendArg(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendArg(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos) );
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
/*
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 8, ptr);
|
||||
ptr += 8;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
*/
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_powersave1_seq);
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1305 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* timing from SSD1306 */
|
||||
static const u8x8_display_info_t u8x8_ssd1305_128x32_noname_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 2,
|
||||
/* flipmode_x_offset = */ 2,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1305_128x32_noname_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */
|
||||
U8X8_CA(0x0d3, 32), /* display offset to 32 */
|
||||
U8X8_C(0x040), /* set display start line to 0 */
|
||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
|
||||
U8X8_CA(0x081, 0x0cf), /* [2] set contrast control */
|
||||
U8X8_CA(0x0d9, 0x0f1), /* [2] pre-charge period 0x022/f1*/
|
||||
U8X8_CA(0x0db, 0x040), /* vcomh deselect level */
|
||||
// if vcomh is 0, then this will give the biggest range for contrast control issue #98
|
||||
// restored the old values for the noname constructor, because vcomh=0 will not work for all OLEDs, #116
|
||||
|
||||
U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_ssd1305_128x32_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_ssd1305_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_noname_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1305_128x32_noname_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*================================================*/
|
||||
/* adafruit 128x32 SSD1305 OLED, https://www.adafruit.com/product/2675 */
|
||||
/* issue 724 */
|
||||
|
||||
/* timing from SSD1306 */
|
||||
static const u8x8_display_info_t u8x8_ssd1305_128x32_adafruit_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 4,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_ssd1305_128x32_adafruit(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_ssd1305_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_noname_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1305_128x32_adafruit_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*================================================*/
|
||||
/* adafruit SSD1305 OLED */
|
||||
|
||||
/* timing from SSD1306 */
|
||||
static const u8x8_display_info_t u8x8_ssd1305_128x64_adafruit_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 2,
|
||||
/* flipmode_x_offset = */ 2,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1305_128x64_adafruit_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x0f0), /* clock divide ratio (0x00=1) and oscillator frequency */
|
||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */
|
||||
U8X8_CA(0x0d3, 0x040), /* display offset to 32 */
|
||||
U8X8_C(0x040), /* set display start line to 0 */
|
||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
|
||||
U8X8_CA(0x081, 0x032), /* [2] set contrast control */
|
||||
U8X8_CA(0x082, 0x080), /* set area brightness (reset=0x080) */
|
||||
U8X8_CA(0x0d9, 0x0f1), /* [2] pre-charge period 0x022/f1*/
|
||||
U8X8_CA(0x0db, 0x040), /* vcomh deselect level */
|
||||
// if vcomh is 0, then this will give the biggest range for contrast control issue #98
|
||||
// restored the old values for the noname constructor, because vcomh=0 will not work for all OLEDs, #116
|
||||
|
||||
U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_ssd1305_128x64_adafruit(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_ssd1305_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x64_adafruit_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1305_128x64_adafruit_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*================================================*/
|
||||
/* Raystar RET012864 OLED, issue https://github.com/olikraus/u8g2/issues/1111 */
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1305_128x64_raystar_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 4,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1305_128x64_raystar(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_ssd1305_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x64_adafruit_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1305_128x64_raystar_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
323
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1306_128x32.c
Normal file
323
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1306_128x32.c
Normal file
@@ -0,0 +1,323 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1306_128x32.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
/* UG-2832HSWEG02 Datasheet, Section 4.4 */
|
||||
static const uint8_t u8x8_d_ssd1306_128x32_univision_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0a8, 0x01f), /* multiplex ratio */
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
||||
U8X8_C(0x040), /* set display start line to 0 */
|
||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x002), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
U8X8_CA(0x081, 0x08f), /* [2] set contrast control */
|
||||
U8X8_CA(0x0d9, 0x0f1), /* [2] pre-charge period 0x022/f1*/
|
||||
U8X8_CA(0x0db, 0x040), /* vcomh deselect level */
|
||||
|
||||
U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_128x32_univision_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_128x32_univision_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_128x32_univision_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_128x32_univision_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1306_128x32_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x32_univision_display_info);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x32_univision_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x32_univision_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x32_univision_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x32_univision_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x32_univision_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
/*
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 8, ptr);
|
||||
ptr += 8;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
*/
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1306_128x32_univision_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1306_128x32_univision(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x32_univision_display_info);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1306_128x32_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
/*=============================================*/
|
||||
/* issue 756 */
|
||||
|
||||
#define ADDR_MODE 0 //0:horizontal, 1:vertical, 2:page
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1306_128x32_winstar_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 125,
|
||||
/* flipmode_x_offset = */ 125,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1306_128x32_winstar(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x32_winstar_display_info);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1306_128x32_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
/*=============================================*/
|
||||
/* visionox 132x32 OLED, https://github.com/olikraus/u8g2/issues/1250 */
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_sh1106_128x32_visionox_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0xAE),
|
||||
U8X8_CA(0xD5, 0x91),
|
||||
U8X8_CA(0xA8, 0x1F),
|
||||
U8X8_CA(0xD3, 0x10),
|
||||
U8X8_C(0x40),
|
||||
U8X8_CA(0xAD, 0x8B),
|
||||
U8X8_C(0x33),
|
||||
U8X8_C(0xA1),
|
||||
U8X8_C(0xC8),
|
||||
U8X8_CA(0xDA, 0x12),
|
||||
U8X8_CA(0x81, 0xAF),
|
||||
U8X8_CA(0xD9, 0x1F),
|
||||
U8X8_CA(0xDB, 0x25),
|
||||
U8X8_C(0xA4),
|
||||
U8X8_C(0xA6),
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const u8x8_display_info_t u8x8_d_sh1106_128x32_visionox_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 2,
|
||||
/* flipmode_x_offset = */ 2,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_sh1106_128x32_visionox(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_d_sh1106_128x32_visionox_display_info);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_128x32_visionox_init_seq);
|
||||
}
|
||||
|
||||
return u8x8_d_ssd1306_128x32_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
@@ -0,0 +1,465 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1306_128x64_noname.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
/* more or less generic setup of all these small OLEDs */
|
||||
static const uint8_t u8x8_d_ssd1306_128x64_noname_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
||||
U8X8_C(0x040), /* set display start line to 0 */
|
||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, SSD1306 only, should be removed for SH1106 */
|
||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
|
||||
U8X8_CA(0x081, 0x0cf), /* [2] set contrast control */
|
||||
U8X8_CA(0x0d9, 0x0f1), /* [2] pre-charge period 0x022/f1*/
|
||||
U8X8_CA(0x0db, 0x040), /* vcomh deselect level */
|
||||
// if vcomh is 0, then this will give the biggest range for contrast control issue #98
|
||||
// restored the old values for the noname constructor, because vcomh=0 will not work for all OLEDs, #116
|
||||
|
||||
U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
/* this setup maximizes the brightness range, that can be set with setContrast() */
|
||||
/* Drawback: VCOMH deselect level is set to 0, which das not work so good with all OLEDs, issue #116 */
|
||||
static const uint8_t u8x8_d_ssd1306_128x64_vcomh0_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
||||
U8X8_C(0x040), /* set display start line to 0 */
|
||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
U8X8_CA(0x081, 0x0ef), /* [2] set contrast control, */
|
||||
U8X8_CA(0x0d9, 0x0a1), /* [2] pre-charge period 0x022/f1*/
|
||||
U8X8_CA(0x0db, 0x000), /* vcomh deselect level 0x000 .. 0x070, low nibble always 0 */
|
||||
// if vcomh is 0, then this will give the biggest range for contrast control issue #98
|
||||
|
||||
U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/* same as u8x8_d_ssd1306_128x64_noname_init_seq, but 0x0da bit 4 is set to 0 */
|
||||
/* this will disable the alternative COM configuration */
|
||||
static const uint8_t u8x8_d_ssd1306_128x64_alt0_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
||||
U8X8_C(0x040), /* set display start line to 0 */
|
||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, SSD1306 only, should be removed for SH1106 */
|
||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x002), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
|
||||
U8X8_CA(0x081, 0x0cf), /* [2] set contrast control */
|
||||
U8X8_CA(0x0d9, 0x0f1), /* [2] pre-charge period 0x022/f1*/
|
||||
U8X8_CA(0x0db, 0x040), /* vcomh deselect level */
|
||||
// if vcomh is 0, then this will give the biggest range for contrast control issue #98
|
||||
// restored the old values for the noname constructor, because vcomh=0 will not work for all OLEDs, #116
|
||||
|
||||
U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* issue 316: a special sh1106 setup, https://www.mikrocontroller.net/topic/431371?goto=5087807#5087807 */
|
||||
static const uint8_t u8x8_d_sh1106_128x64_winstar_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0xae), // Display OFF/ON: off (POR = 0xae)
|
||||
U8X8_C(0xa4), // Set Entire Display OFF/ON: off (POR = 0xa4)
|
||||
U8X8_CA(0xd5, 0x50), // Divide Ratio/Oscillator FrequencyData Set: divide ratio = 1 (POR = 1), Oscillator Frequency = +/- 0% (POR = +/- 0%)
|
||||
U8X8_CA(0xa8, 0x3f), // Multiplex Ratio Data Set: 64 (POR = 0x3f, 64)
|
||||
U8X8_CA(0xd3, 0x00), // Display OffsetData Set: 0 (POR = 0x00)
|
||||
U8X8_C(0x40), // Set Display Start Line: 0
|
||||
U8X8_CA(0xad, 0x8b), // DC-DC ON/OFF Mode Set: Built-in DC-DC is used, Normal Display (POR = 0x8b)
|
||||
U8X8_CA(0xd9, 0x22), // Dis-charge/Pre-charge PeriodData Set: pre-charge 2 DCLKs, dis-charge 2 DCLKs (POR = 0x22, pre-charge 2 DCLKs, dis-charge 2 DCLKs)
|
||||
U8X8_CA(0xdb, 0x35), // VCOM Deselect LevelData Set: 0,770V (POR = 0x35, 0,770 V)
|
||||
U8X8_C(0x32), // Set Pump voltage value: 8,0 V (POR = 0x32, 8,0 V)
|
||||
U8X8_CA(0x81, 0xff), // Contrast Data Register Set: 255 (large) (POR = 0x80)
|
||||
U8X8_C(0x0a6), // Set Normal/Reverse Display: normal (POR = 0xa6)
|
||||
U8X8_CA(0x0da, 0x012), // com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5)
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_128x64_noname_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_128x64_noname_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_128x64_noname_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_128x64_noname_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1306_sh1106_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x64_noname_display_info);
|
||||
break;
|
||||
*/
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x040 ); /* set line offset to 0 */
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendArg(u8x8, 0x000 | ((x&15))); /* probably wrong, should be SendCmd */
|
||||
u8x8_cad_SendArg(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos)); /* probably wrong, should be SendCmd */
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
/*
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 8, ptr);
|
||||
ptr += 8;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
*/
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1306_128x64_noname_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1306_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_ssd1306_sh1106_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x64_noname_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8x8_d_ssd1306_128x64_vcomh0(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_ssd1306_sh1106_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_vcomh0_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x64_noname_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8x8_d_ssd1306_128x64_alt0(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_ssd1306_sh1106_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_alt0_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x64_noname_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_sh1106_128x64_noname_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
||||
/* spi_mode = */ 3, /* active low (clock is high by default), rising edge, this seems to be a difference to the ssd1306 */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 2,
|
||||
/* flipmode_x_offset = */ 2,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_sh1106_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( u8x8_d_ssd1306_sh1106_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
/* maybe use a better init sequence */
|
||||
/* https://www.mikrocontroller.net/topic/431371 */
|
||||
/* the new sequence is added in the winstar constructor (see below), this is kept untouched */
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1106_128x64_noname_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
uint8_t u8x8_d_sh1106_128x64_vcomh0(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( u8x8_d_ssd1306_sh1106_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_vcomh0_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1106_128x64_noname_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
uint8_t u8x8_d_sh1106_128x64_winstar(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( u8x8_d_ssd1306_sh1106_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_128x64_winstar_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1106_128x64_noname_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
213
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1306_2040x16.c
Normal file
213
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1306_2040x16.c
Normal file
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1306_2040x16.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
/* virtual device, issue 1291 */
|
||||
static const uint8_t u8x8_d_ssd1306_2040x16_init_seq[] =
|
||||
{
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio, 0.71 OLED: changed from 0x2f to 0x3f */
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset, 0.71 OLED */
|
||||
U8X8_C(0x040), /* set display start line to 0, 0.71 OLED */
|
||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, 0.71 OLED 0x14*/
|
||||
|
||||
/// according to the datasheet, 0x00 is NOT page addressing mode, but horizontal addressing mode;
|
||||
/// so it looks like u8g2 expects horizontal addressing (and the inline comment is wrong) while the Winstar example
|
||||
/// actually uses page addressing (which is the reset default)
|
||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1, 0.71 OLED */
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse, 0.71 OLED */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), 0.71 OLED */
|
||||
U8X8_CA(0x081, 0x07f), /* [2] set contrast control, 0.71 OLED datasheet: 0x7f */
|
||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1, 0.71 OLED datasheet: 0x22 */
|
||||
U8X8_CA(0x0db, 0x040), /* vcomh deselect level, 0.71 OLED datasheet: 0x40 */
|
||||
|
||||
// U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_2040x16_powersave0_seq[] =
|
||||
{
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_2040x16_powersave1_seq[] =
|
||||
{
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_2040x16_flip0_seq[] =
|
||||
{
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_2040x16_flip1_seq[] =
|
||||
{
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static uint8_t u8x8_d_ssd1306_2040x16_generic(u8x8_t *u8x8, uint8_t msg,
|
||||
uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch (msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_2040x16_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_2040x16_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if (arg_int == 0)
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_2040x16_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_2040x16_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if (arg_int == 0)
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_2040x16_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_2040x16_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081);
|
||||
u8x8_cad_SendArg(u8x8, arg_int); /* ssd1306 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *) arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4));
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x & 15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *) arg_ptr)->y_pos));
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *) arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *) arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c * 8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while (arg_int > 0);
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1306_2040x16_display_info =
|
||||
{
|
||||
/* chip_enable_level = */0,
|
||||
/* chip_disable_level = */1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */20,
|
||||
/* pre_chip_disable_wait_ns = */10,
|
||||
/* reset_pulse_width_ms = */100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
||||
/* spi_mode = */0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */4,
|
||||
/* data_setup_time_ns = */40,
|
||||
/* write_pulse_width_ns = */150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */255,
|
||||
/* tile_height = */2,
|
||||
/* default_x_offset = */0,
|
||||
/* flipmode_x_offset = */0,
|
||||
/* pixel_width = */2040,
|
||||
/* pixel_height = */16 };
|
||||
|
||||
uint8_t u8x8_d_ssd1306_2040x16(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if (msg == U8X8_MSG_DISPLAY_SETUP_MEMORY)
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_2040x16_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if (msg == U8X8_MSG_DISPLAY_INIT)
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_2040x16_init_seq);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1306_2040x16_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
215
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1306_48x64.c
Normal file
215
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1306_48x64.c
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1306_48x64_winstar.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
/* Winstar 0.71 OLED */
|
||||
static const uint8_t u8x8_d_ssd1306_48x64_winstar_init_seq[] =
|
||||
{
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio, 0.71 OLED: changed from 0x2f to 0x3f */
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset, 0.71 OLED */
|
||||
U8X8_C(0x040), /* set display start line to 0, 0.71 OLED */
|
||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, 0.71 OLED 0x14*/
|
||||
|
||||
/// according to the datasheet, 0x00 is NOT page addressing mode, but horizontal addressing mode;
|
||||
/// so it looks like u8g2 expects horizontal addressing (and the inline comment is wrong) while the Winstar example
|
||||
/// actually uses page addressing (which is the reset default)
|
||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1, 0.71 OLED */
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse, 0.71 OLED */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), 0.71 OLED */
|
||||
U8X8_CA(0x081, 0x07f), /* [2] set contrast control, 0.71 OLED datasheet: 0x7f */
|
||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1, 0.71 OLED datasheet: 0x22 */
|
||||
U8X8_CA(0x0db, 0x040), /* vcomh deselect level, 0.71 OLED datasheet: 0x40 */
|
||||
|
||||
// U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_48x64_powersave0_seq[] =
|
||||
{
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_48x64_powersave1_seq[] =
|
||||
{
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_48x64_flip0_seq[] =
|
||||
{
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_48x64_flip1_seq[] =
|
||||
{
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static uint8_t u8x8_d_ssd1306_48x64_generic(u8x8_t *u8x8, uint8_t msg,
|
||||
uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch (msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_48x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_48x64_winstar_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if (arg_int == 0)
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_48x64_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_48x64_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if (arg_int == 0)
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_48x64_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_48x64_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081);
|
||||
u8x8_cad_SendArg(u8x8, arg_int); /* ssd1306 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *) arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4));
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x & 15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *) arg_ptr)->y_pos));
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *) arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *) arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c * 8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while (arg_int > 0);
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1306_48x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */0,
|
||||
/* chip_disable_level = */1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */20,
|
||||
/* pre_chip_disable_wait_ns = */10,
|
||||
/* reset_pulse_width_ms = */100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
||||
/* spi_mode = */0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */4,
|
||||
/* data_setup_time_ns = */40,
|
||||
/* write_pulse_width_ns = */150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */6,
|
||||
/* tile_height = */8,
|
||||
/* default_x_offset = */40,
|
||||
/* flipmode_x_offset = */40,
|
||||
/* pixel_width = */48,
|
||||
/* pixel_height = */64 };
|
||||
|
||||
/* Winstar 0.71" OLED */
|
||||
uint8_t u8x8_d_ssd1306_48x64_winstar(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int,
|
||||
void *arg_ptr)
|
||||
{
|
||||
if (msg == U8X8_MSG_DISPLAY_SETUP_MEMORY)
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_48x64_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if (msg == U8X8_MSG_DISPLAY_INIT)
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_48x64_winstar_init_seq);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1306_48x64_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
258
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1306_64x32.c
Normal file
258
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1306_64x32.c
Normal file
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1306_64x32.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_64x32_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_64x32_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_64x32_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_64x32_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1306_64x32_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_64x32_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x32_noname_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x32_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x32_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x32_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x32_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*======================================================*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1306_64x32_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 8,
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 32,
|
||||
/* flipmode_x_offset = */ 32,
|
||||
/* pixel_width = */ 64,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
|
||||
/*======================================================*/
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_64x32_noname_init_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0a8, 0x02f), /* multiplex ratio: changed from 0x1f to 0x2f */
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
||||
U8X8_C(0x040), /* set display start line to 0 */
|
||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1 */
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
U8X8_CA(0x081, 0x0cf), /* [2] set contrast control datasheet: 0xcf */
|
||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1 */
|
||||
U8X8_CA(0x0db, 0x000), /* vcomh deselect level */
|
||||
|
||||
U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1306_64x32_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_64x32_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x32_noname_init_seq);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1306_64x32_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
/*======================================================*/
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_64x32_1f_init_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0a8, 0x01f), /* multiplex ratio: changed from 0x1f to 0x2f, 23 Sep 17: changed back to 1f */
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
||||
U8X8_C(0x040), /* set display start line to 0 */
|
||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1 */
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
U8X8_CA(0x081, 0x0cf), /* [2] set contrast control datasheet: 0xcf */
|
||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1 */
|
||||
U8X8_CA(0x0db, 0x000), /* vcomh deselect level */
|
||||
|
||||
U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1306_64x32_1f(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_64x32_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x32_1f_init_seq);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1306_64x32_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
213
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1306_64x48.c
Normal file
213
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1306_64x48.c
Normal file
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1306_64x48.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
/* EastRising 0.66 OLED */
|
||||
static const uint8_t u8x8_d_ssd1306_64x48_er_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0a8, 0x02f), /* multiplex ratio, 0.66 OLED: changed from 0x1f to 0x2f */
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset, 0.66 OLED */
|
||||
U8X8_C(0x040), /* set display start line to 0, 0.66 OLED */
|
||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, 0.66 OLED 0x14*/
|
||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1, 0.66 OLED */
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse, 0.66 OLED */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), 0.66 OLED */
|
||||
U8X8_CA(0x081, 0x0cf), /* [2] set contrast control, 0.66 OLED datasheet: 0xcf */
|
||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1, 0.66 OLED datasheet: 0x22 */
|
||||
U8X8_CA(0x0db, 0x000), /* vcomh deselect level, 0.66 OLED datasheet: 0x00 */
|
||||
|
||||
U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_64x48_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_64x48_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_64x48_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_64x48_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1306_64x48_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_64x48_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x48_er_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x48_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x48_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x48_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x48_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1306_64x48_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 8,
|
||||
/* tile_hight = */ 6,
|
||||
/* default_x_offset = */ 32,
|
||||
/* flipmode_x_offset = */ 32,
|
||||
/* pixel_width = */ 64,
|
||||
/* pixel_height = */ 48
|
||||
};
|
||||
|
||||
/* East Rising 0.66" OLED */
|
||||
uint8_t u8x8_d_ssd1306_64x48_er(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_64x48_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x48_er_init_seq);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1306_64x48_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
266
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1306_72x40.c
Normal file
266
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1306_72x40.c
Normal file
@@ -0,0 +1,266 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1306_72x40.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2019, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
EastRising 0.41 OLED
|
||||
https://www.buydisplay.com/default/white-0-42-inch-oled-display-panel-72x40-iic-i2c-serial-spi-ssd1306
|
||||
|
||||
|
||||
command(0xae);//--turn off oled panel
|
||||
|
||||
command(0xd5);//--set display clock divide ratio/oscillator frequency
|
||||
command(0x80);//--set divide ratio
|
||||
|
||||
command(0xa8);//--set multiplex ratio
|
||||
command(0x27);//--1/40 duty
|
||||
|
||||
command(0xd3);//-set display offset
|
||||
command(0x00);//-not offset
|
||||
|
||||
command(0xad);//--Internal IREF Setting
|
||||
command(0x30);//--
|
||||
|
||||
command(0x8d);//--set Charge Pump enable/disable
|
||||
command(0x14);//--set(0x10) disable
|
||||
|
||||
command(0x40);//--set start line address
|
||||
|
||||
command(0xa6);//--set normal display
|
||||
|
||||
command(0xa4);//Disable Entire Display On
|
||||
|
||||
command(0xa1);//--set segment re-map 128 to 0
|
||||
|
||||
command(0xC8);//--Set COM Output Scan Direction 64 to 0
|
||||
|
||||
command(0xda);//--set com pins hardware configuration
|
||||
command(0x12);
|
||||
|
||||
command(0x81);//--set contrast control register
|
||||
command(0xaf);
|
||||
|
||||
command(0xd9);//--set pre-charge period
|
||||
command(0x22);
|
||||
|
||||
command(0xdb);//--set vcomh
|
||||
command(0x20);
|
||||
|
||||
command(0xaf);//--turn on oled panel
|
||||
|
||||
|
||||
*/
|
||||
static const uint8_t u8x8_d_ssd1306_72x40_er_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0a8, 0x027), /* multiplex ratio, 0.42 OLED: 0x27*/
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset, 0.42 OLED */
|
||||
U8X8_CA(0x0ad, 0x030), /* Internal IREF Setting for the 0.42 OLED, see also issue https://github.com/olikraus/u8g2/issues/1047 */
|
||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, 0.66 OLED 0x14*/
|
||||
|
||||
U8X8_C(0x040), /* set display start line to 0, 0.66 OLED */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
|
||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1, 0.66 OLED */
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse, 0.66 OLED */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), 0.66 OLED */
|
||||
U8X8_CA(0x081, 0x0af), /* [2] set contrast control, 0.42 OLED */
|
||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1, 0.42 OLED datasheet: 0x22 */
|
||||
U8X8_CA(0x0db, 0x020), /* vcomh deselect level, 0.42 OLED datasheet: 0x20 */
|
||||
|
||||
U8X8_C(0x02e), /* Deactivate scroll */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_72x40_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_72x40_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_72x40_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_72x40_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1306_72x40_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_72x40_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_72x40_er_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_72x40_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_72x40_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_72x40_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_72x40_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1306_72x40_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 9,
|
||||
/* tile_hight = */ 5,
|
||||
/* default_x_offset = */ 28,
|
||||
/* flipmode_x_offset = */ 28,
|
||||
/* pixel_width = */ 72,
|
||||
/* pixel_height = */ 40
|
||||
};
|
||||
|
||||
/*
|
||||
EastRising 0.41 OLED
|
||||
https://www.buydisplay.com/default/white-0-42-inch-oled-display-panel-72x40-iic-i2c-serial-spi-ssd1306
|
||||
*/
|
||||
uint8_t u8x8_d_ssd1306_72x40_er(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_72x40_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_72x40_er_init_seq);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1306_72x40_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
213
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1306_96x16.c
Normal file
213
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1306_96x16.c
Normal file
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1306_96x16.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
/* EastRising 0.69 OLED */
|
||||
static const uint8_t u8x8_d_ssd1306_96x16_er_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0a8, 0x00f), /* multiplex ratio, 0.69 OLED: 0x0f */
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset, 0.69 OLED */
|
||||
U8X8_C(0x040), /* set display start line to 0, 0.69 OLED */
|
||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, 0.66 OLED 0x14*/
|
||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1, 0.66 OLED */
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse, 0.66 OLED */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x002), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), 0.66 OLED */
|
||||
U8X8_CA(0x081, 0x0af), /* [2] set contrast control, 0.69 OLED datasheet: 0xaf */
|
||||
U8X8_CA(0x0d9, 0x0f1), /* [2] pre-charge period 0x0f1, 0.69 OLED datasheet: 0xf1 */
|
||||
U8X8_CA(0x0db, 0x020), /* vcomh deselect level, 0.69 OLED datasheet: 0x20 */
|
||||
|
||||
U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_96x16_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_96x16_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_96x16_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1306_96x16_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1306_96x16_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_96x16_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_96x16_er_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_96x16_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_96x16_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_96x16_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_96x16_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1306_96x16_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 12,
|
||||
/* tile_hight = */ 2,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 32,
|
||||
/* pixel_width = */ 96,
|
||||
/* pixel_height = */ 16
|
||||
};
|
||||
|
||||
/* East Rising 0.69" OLED */
|
||||
uint8_t u8x8_d_ssd1306_96x16_er(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_96x16_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_96x16_er_init_seq);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1306_96x16_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
409
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1309.c
Normal file
409
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1309.c
Normal file
@@ -0,0 +1,409 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1309.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2017, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1309_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1309_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1309_128x64_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1309_128x64_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1309_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos) );
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
/*
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 8, ptr);
|
||||
ptr += 8;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
*/
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1309_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1309_powersave1_seq);
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1309 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*=================================================*/
|
||||
/* offset 2 version */
|
||||
|
||||
/* timing from SSD1306 */
|
||||
static const u8x8_display_info_t u8x8_ssd1309_128x64_noname2_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 2,
|
||||
/* flipmode_x_offset = */ 2,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1309_128x64_noname_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x0a0), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
//U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */
|
||||
U8X8_C(0x040), /* set display start line to 0 */
|
||||
U8X8_CA(0x020, 0x002), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
|
||||
U8X8_CA(0x081, 0x06f), /* [2] set contrast control */
|
||||
U8X8_CA(0x0d9, 0x0d3), /* [2] pre-charge period 0x022/f1*/
|
||||
U8X8_CA(0x0db, 0x020), /* vcomh deselect level */
|
||||
// if vcomh is 0, then this will give the biggest range for contrast control issue #98
|
||||
// restored the old values for the noname constructor, because vcomh=0 will not work for all OLEDs, #116
|
||||
|
||||
U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
//U8X8_C(0x0af), /* display on */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_ssd1309_128x64_noname2(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_ssd1309_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1309_128x64_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1309_128x64_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1309_128x64_noname_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1309_128x64_noname2_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*=================================================*/
|
||||
/* offset 0 version */
|
||||
|
||||
/* timing from SSD1306 */
|
||||
static const u8x8_display_info_t u8x8_ssd1309_128x64_noname0_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1309_128x64_noname0(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_ssd1309_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1309_128x64_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1309_128x64_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1309_128x64_noname_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1309_128x64_noname0_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*=================================================*/
|
||||
/*
|
||||
EA OLEDS102
|
||||
Contributed here: https://github.com/olikraus/u8g2/pull/1497/files
|
||||
Manually added here, device renamed from SSD1309 to SSD1306
|
||||
*/
|
||||
|
||||
static const uint8_t u8x8_d_ssd1309_102x64_ea_oleds102_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x40), //Set Display start line
|
||||
U8X8_C(0xA0), //Bottom View no Segment remap
|
||||
U8X8_C(0xC0), //Bottom View COM scan direction normal
|
||||
U8X8_C(0x2E), //StartColumnAddress
|
||||
U8X8_CA(0x8D, 0x95), //Switch Charge Pump (9V)
|
||||
U8X8_CA(0x20, 0x02), //Set Memory AddressMode
|
||||
U8X8_CA(0x81, 0xFF), //Set Brightness
|
||||
U8X8_CA(0xD5, 0x40), //Set Display Clock Divide
|
||||
U8X8_CA(0xD9, 0xF1), //Set Precharge Periode
|
||||
U8X8_CA(0xAD, 0x30), //Set Internal Ref
|
||||
U8X8_CAA(0x21, 0x0D, 0x72), //Set ColumnAddress to 13x8 + 10 = 114/0x72
|
||||
U8X8_CAA(0x22, 0x00, 0x3F), //Set PageAddress
|
||||
U8X8_C(0xAF), //Display on
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
/* timing from SSD1306 */
|
||||
static const u8x8_display_info_t u8x8_ssd1309_102x64_ea_oleds102_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 13, /* width of 13*8=104 pixel */
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 13,
|
||||
/* flipmode_x_offset = */ 13,
|
||||
/* pixel_width = */ 102,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1306_102x64_ea_oleds102(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1309_128x64_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1309_128x64_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1309_102x64_ea_oleds102_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1309_102x64_ea_oleds102_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1309 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
|
||||
if ( c + x > 115u )
|
||||
{
|
||||
c = 115u;
|
||||
c -= x;
|
||||
}
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
236
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1316.c
Normal file
236
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1316.c
Normal file
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1316.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2019, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
SSD1316: 128x39 OLED
|
||||
|
||||
https://github.com/olikraus/u8g2/issues/919
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
static const uint8_t u8x8_d_ssd1316_128x32_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1316_128x32_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1316_128x32_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1316_128x32_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/*===================================================*/
|
||||
|
||||
static uint8_t u8x8_d_ssd1316_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1316_128x32_display_info);
|
||||
break;
|
||||
*/
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1316_128x32_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1316_128x32_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1316_128x32_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1316_128x32_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1316_128x32_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15))); /* probably wrong, should be SendCmd */
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos)); /* probably wrong, should be SendCmd */
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*===================================================*/
|
||||
|
||||
|
||||
/* QT-2832TSWUG02/ZJY-2832TSWZG02 */
|
||||
static const uint8_t u8x8_d_ssd1316_128x32_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_C(0x040), /* start line */
|
||||
U8X8_CA(0x081, 0x045), /* QG-2832TSWZG02 datasheet */
|
||||
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
U8X8_CA(0x0a8, 0x01f), /* multiplex ratio, duty = 1/32 */
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1*/
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
U8X8_CA(0x0db, 0x020), /* vcomh deselect level */
|
||||
U8X8_CA(0x08d, 0x015), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, */
|
||||
|
||||
//U8X8_CA(0x0a2, 0x000), /* set display start line to 0 */
|
||||
//U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
|
||||
// Flipmode
|
||||
//U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
//U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_C(0x02e), /* Deactivate scroll */
|
||||
//U8X8_C(0x0a4), /* output ram to display */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1316_128x32_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* reset time */
|
||||
/* post_reset_wait_ms = */ 100, /* reset delay */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1316_128x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_ssd1316_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1316_128x32_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1316_128x32_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
241
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1317.c
Normal file
241
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1317.c
Normal file
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1317.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2018, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
SSD1317: 128x96 OLED
|
||||
|
||||
https://github.com/olikraus/u8g2/issues/663
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
/* more or less generic setup of all these small OLEDs */
|
||||
static const uint8_t u8x8_d_ssd1317_96x96_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0d5, 0x0d1), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
U8X8_CA(0x0a8, 0x05f), /* multiplex ratio */
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
||||
U8X8_CA(0x0a2, 0x000), /* set display start line to 0 */
|
||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, SSD1306 only, should be removed for SH1106 */
|
||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
// Flipmode
|
||||
//U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
//U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
|
||||
U8X8_CA(0x081, 0x09f), /* [2] set contrast control */
|
||||
U8X8_CA(0x0d9, 0x0f1), /* [2] pre-charge period 0x022/f1*/
|
||||
U8X8_CA(0x0db, 0x0ff), /* vcomh deselect level */
|
||||
|
||||
// if vcomh is 0, then this will give the biggest range for contrast control issue #98
|
||||
// restored the old values for the noname constructor, because vcomh=0 will not work for all OLEDs, #116
|
||||
|
||||
U8X8_C(0x02e), /* Deactivate scroll */
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1317_96x96_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1317_96x96_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1317_96x96_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1317_96x96_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1317_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1317_96x96_display_info);
|
||||
break;
|
||||
*/
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1317_96x96_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1317_96x96_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1317_96x96_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1317_96x96_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1317_96x96_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x040 ); /* set line offset to 0 */
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendArg(u8x8, 0x000 | ((x&15))); /* probably wrong, should be SendCmd */
|
||||
u8x8_cad_SendArg(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos)); /* probably wrong, should be SendCmd */
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
/*
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 8, ptr);
|
||||
ptr += 8;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
*/
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1317_96x96_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 12,
|
||||
/* tile_hight = */ 12,
|
||||
/* default_x_offset = */ 16,
|
||||
/* flipmode_x_offset = */ 16,
|
||||
/* pixel_width = */ 96,
|
||||
/* pixel_height = */ 96
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1317_96x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_ssd1317_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1317_96x96_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1317_96x96_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
317
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1318.c
Normal file
317
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1318.c
Normal file
@@ -0,0 +1,317 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1318.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2019, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
SSD1318: 128x96 OLED
|
||||
|
||||
https://github.com/olikraus/u8g2/issues/784
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
/* with internal charge pump (icp) */
|
||||
static const uint8_t u8x8_d_ssd1318_128x96_icp_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_CA(0x0fd, 0x012), /* unlock */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0ad, 0x0d0), /* external or internal IREF selection */
|
||||
U8X8_CA(0x0a8, 0x05f), /* multiplex ratio, 96 duty */
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
||||
U8X8_CA(0x0a2, 0x000), /* start line */
|
||||
|
||||
|
||||
// four possible charge pump setting from as per sec 6.8.2 of the ssd1318 datasheet
|
||||
// uncomment only one of the below for lines
|
||||
// default:
|
||||
// U8X8_CA(0x08d, 0x004, 0x0ac, 0x001), /* Charge pump setting from sec 6.8.2 of SSD1318 datasheet */
|
||||
// U8X8_CA(0x08d, 0x044, 0x0ac, 0x001), /* Charge pump setting from sec 6.8.2 of SSD1318 datasheet */
|
||||
// U8X8_CA(0x08d, 0x084, 0x0ac, 0x001), /* Charge pump setting from sec 6.8.2 of SSD1318 datasheet */
|
||||
U8X8_CAAA(0x08d, 0x0c4, 0x0ac, 0x001), /* Charge pump setting from sec 6.8.2 of SSD1318 datasheet */
|
||||
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
|
||||
U8X8_CA(0x081, 0x00f), /* value from issue 784, seems to be a little bit low... */
|
||||
|
||||
|
||||
U8X8_CA(0x0d5, 0x0d1), /* clock divide ratio (0x00=1) and oscillator frequency (0x8), value from issue 784 example code */
|
||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1, value from issue 784 example code */
|
||||
U8X8_CA(0x0db, 0x030), /* vcomh deselect level, value from issue 784 example code */
|
||||
|
||||
|
||||
//U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
//U8X8_C(0x02e), /* Deactivate scroll */
|
||||
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/* with external charge pump */
|
||||
static const uint8_t u8x8_d_ssd1318_128x96_xcp_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_CA(0x0fd, 0x012), /* unlock */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0ad, 0x0d0), /* external or internal IREF selection */
|
||||
U8X8_CA(0x0a8, 0x05f), /* multiplex ratio, 96 duty */
|
||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
||||
U8X8_CA(0x0a2, 0x000), /* start line */
|
||||
|
||||
|
||||
// not sure if we have to set something for external charge pump
|
||||
// ...
|
||||
|
||||
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
|
||||
U8X8_CA(0x081, 0x00f), /* value from issue 784, seems to be a little bit low... */
|
||||
|
||||
|
||||
U8X8_CA(0x0d5, 0x0d1), /* clock divide ratio (0x00=1) and oscillator frequency (0x8), value from issue 784 example code */
|
||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1, value from issue 784 example code */
|
||||
U8X8_CA(0x0db, 0x030), /* vcomh deselect level, value from issue 784 example code */
|
||||
|
||||
|
||||
//U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
||||
//U8X8_C(0x02e), /* Deactivate scroll */
|
||||
|
||||
U8X8_C(0x0a4), /* output ram to display */
|
||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1318_128x96_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1318_128x96_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1318_128x96_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1318_128x96_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1318_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1318_128x96_display_info);
|
||||
break;
|
||||
*/
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1318_128x96_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1318_128x96_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1318_128x96_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1318_128x96_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1318_128x96_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1318 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x040 ); /* set line offset to 0 */
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendArg(u8x8, 0x000 | ((x&15))); /* probably wrong, should be SendCmd */
|
||||
u8x8_cad_SendArg(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos)); /* probably wrong, should be SendCmd */
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
/*
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 8, ptr);
|
||||
ptr += 8;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
*/
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1318_128x96_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 12,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 96
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1318_128x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_ssd1318_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1318_128x96_icp_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1318_128x96_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8x8_d_ssd1318_128x96_xcp(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_ssd1318_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1318_128x96_xcp_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1318_128x96_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
494
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1320.c
Normal file
494
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1320.c
Normal file
@@ -0,0 +1,494 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1320.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2020, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
https://github.com/olikraus/u8g2/issues/1351
|
||||
SSD1320:
|
||||
160 x 160 dot matrix
|
||||
16 gray scale
|
||||
|
||||
Adapted from u8x8_d_ssd1322.c with the command set of the SSD1320 controller
|
||||
"official" procedure is described here: https://github.com/olikraus/u8g2/wiki/internal
|
||||
|
||||
NOTE: U8x8 does NOT work!
|
||||
|
||||
*/
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
static const uint8_t u8x8_d_ssd1320_cs1_160x132_nhd_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* ssd1320: display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1320_cs1_160x132_nhd_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* ssd1320: display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
input:32
|
||||
one tile (8 Bytes; 1 byte per column)
|
||||
output:
|
||||
Tile for SSD1320 (32 Bytes)
|
||||
|
||||
The origin of the display seems to be in the upper right-hand corner. Therefore
|
||||
compared to SSD1322, the order inside each byte is swapped.
|
||||
*/
|
||||
|
||||
static uint8_t u8x8_ssd1320_to32_dest_buf[32];
|
||||
|
||||
static uint8_t *u8x8_ssd1320_8to32(U8X8_UNUSED u8x8_t *u8x8, uint8_t *ptr)
|
||||
{
|
||||
uint8_t v;
|
||||
uint8_t a,b;
|
||||
uint8_t i, j;
|
||||
uint8_t *dest;
|
||||
|
||||
for( j = 0; j < 4; j++ )
|
||||
{
|
||||
dest = u8x8_ssd1320_to32_dest_buf;
|
||||
dest += j;
|
||||
a =*ptr;
|
||||
ptr++;
|
||||
b = *ptr;
|
||||
ptr++;
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
v = 0;
|
||||
if ( a&1 ) v |= 0x0f;
|
||||
if ( b&1 ) v |= 0xf0;
|
||||
*dest = v;
|
||||
dest+=4;
|
||||
a >>= 1;
|
||||
b >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return u8x8_ssd1320_to32_dest_buf;
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8x8_d_ssd1320_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x;
|
||||
uint8_t y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* U8X8_MSG_DISPLAY_SETUP_MEMORY is handled by the calling function */
|
||||
/*
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1320_256x64_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1320_cs1_160x132_nhd_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1320_cs1_160x132_nhd_powersave1_seq);
|
||||
break;
|
||||
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1320 has range from 1 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
x += u8x8->x_offset;
|
||||
|
||||
y *= 8;
|
||||
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x022 ); /* set row address, moved out of the loop (issue 302) */
|
||||
u8x8_cad_SendArg(u8x8, y);
|
||||
u8x8_cad_SendArg(u8x8, y+7);
|
||||
|
||||
do {
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
|
||||
do {
|
||||
u8x8_cad_SendCmd(u8x8, 0x021 ); /* set column address */
|
||||
u8x8_cad_SendArg(u8x8, x ); /* start */
|
||||
u8x8_cad_SendArg(u8x8, x+3 ); /* end */
|
||||
|
||||
u8x8_cad_SendData(u8x8, 32, u8x8_ssd1320_8to32(u8x8, ptr));
|
||||
|
||||
ptr += 8;
|
||||
x += 4;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
|
||||
//x += 2;
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*=========================================================*/
|
||||
/* 160x32 */
|
||||
|
||||
static const uint8_t u8x8_d_ssd1320_cs1_160x32_nhd_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* remap */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1320_cs1_160x32_nhd_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* remap */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const u8x8_display_info_t u8x8_d_ssd1320_cs1_160x32_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* ssd1320: 2 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* ssd1320: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* ssd1320: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 10000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215), 10 MHz (issue 301) */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 10,
|
||||
/* write_pulse_width_ns = */ 150, /* ssd1320: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 20, /* 160 pixel, so we require 20 bytes for this */
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 0, /* this is the byte offset (there are two pixel per byte with 4 bit per pixel) */
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 160,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
// initialisation sequence from the Arduino Library
|
||||
// (see https://github.com/sparkfun/SparkFun_SSD1320_OLED_Arduino_Library)
|
||||
static const uint8_t u8x8_d_ssd1320_cs1_160x32_init_seq[] = {
|
||||
|
||||
U8X8_DLY(1),
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(1),
|
||||
|
||||
U8X8_C(0xae), /* display off */
|
||||
U8X8_CA(0xd5, 0xC2), /* set display clock divide ratio/oscillator frequency (set clock as 80 frames/sec) */
|
||||
U8X8_CA(0xa8, 0x1f), /* multiplex ratio 1/64 Duty (0x0F~0x3F) */
|
||||
U8X8_CA(0xa2, 0x00), /* display start line */
|
||||
|
||||
U8X8_C(0xa0), /* Set Segment Re-Map: column address 0 mapped to SEG0 CS1 */
|
||||
// U8X8_C(0xa1), /* Set Segment Re-Map: column address 0 mapped to SEG0 CS2 */
|
||||
|
||||
U8X8_C(0xc8), /* Set COM Output Scan Direction: normal mode CS1 */
|
||||
// U8X8_C(0xc0), /* Set COM Output Scan Direction: normal mode CS2 */
|
||||
|
||||
U8X8_CA(0xd3, 0x72), /* CS1 */
|
||||
// U8X8_CA(0xd3, 0x92), /* CS2 */
|
||||
|
||||
U8X8_CA(0xda, 0x12), /* Set SEG Pins Hardware Configuration: */
|
||||
U8X8_CA(0x81, 0x5a), /* contrast */
|
||||
U8X8_CA(0xd9, 0x22), /* Set Phase Length */
|
||||
U8X8_CA(0xdb, 0x30), /* VCOMH Deselect Level */
|
||||
U8X8_CA(0xad, 0x10), /* Internal IREF Enable */
|
||||
U8X8_CA(0x20, 0x00), /* Memory Addressing Mode: Horizontal */
|
||||
U8X8_CA(0x8d, 0x01), /* disable internal charge pump 1 */
|
||||
U8X8_CA(0xac, 0x00), /* disable internal charge pump 2 */
|
||||
U8X8_C(0xa4), /* display on */
|
||||
U8X8_C(0xa6), /* normal display */
|
||||
|
||||
U8X8_DLY(1), /* delay 2ms */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_ssd1320_160x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_d_ssd1320_cs1_160x32_display_info);
|
||||
break;
|
||||
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1320_cs1_160x32_init_seq);
|
||||
break;
|
||||
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 ){
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1320_cs1_160x32_nhd_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1320_cs1_160x32_nhd_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return u8x8_d_ssd1320_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*=========================================================*/
|
||||
/* 160x132 (actually 320x132) */
|
||||
|
||||
static const uint8_t u8x8_d_ssd1320_cs1_160x132_nhd_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* remap */
|
||||
U8X8_C(0xc8), /* Set COM Output Scan Direction: normal mode CS1 */
|
||||
U8X8_CA(0xd3, 0x0e), /* CS1 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1320_cs1_160x132_nhd_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* remap */
|
||||
U8X8_C(0xc0), /* Set COM Output Scan Direction: normal mode CS1 */
|
||||
U8X8_CA(0xd3, 0x92), /* CS1 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const u8x8_display_info_t u8x8_d_ssd1320_cs1_160x132_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* ssd1320: 2 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* ssd1320: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* ssd1320: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 10000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215), 10 MHz (issue 301) */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 10,
|
||||
/* write_pulse_width_ns = */ 150, /* ssd1320: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 20, /* 160 pixel, so we require 20 bytes for this */
|
||||
/* tile_hight = */ 17,
|
||||
/* default_x_offset = */ 0, /* this is the byte offset (there are two pixel per byte with 4 bit per pixel) */
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 160,
|
||||
/* pixel_height = */ 132
|
||||
};
|
||||
|
||||
|
||||
/* the following sequence will work, but requires contrast to be very high */
|
||||
static const uint8_t u8x8_d_ssd1320_cs1_160x132_init_seq[] = {
|
||||
|
||||
U8X8_DLY(1),
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(1),
|
||||
|
||||
U8X8_C(0xae), /* display off */
|
||||
U8X8_CA(0xd5, 0xC2), /* set display clock divide ratio/oscillator frequency (set clock as 80 frames/sec) */
|
||||
U8X8_CA(0xa8, 0x83), /* multiplex ratio 1/132 Duty */
|
||||
U8X8_CA(0xa2, 0x00), /* display start line */
|
||||
|
||||
U8X8_C(0xa0), /* Set Segment Re-Map: column address 0 mapped to SEG0 CS1 */
|
||||
// U8X8_C(0xa1), /* Set Segment Re-Map: column address 0 mapped to SEG0 CS2 */
|
||||
|
||||
U8X8_C(0xc8), /* Set COM Output Scan Direction: normal mode CS1 */
|
||||
// U8X8_C(0xc0), /* Set COM Output Scan Direction: normal mode CS2 */
|
||||
|
||||
U8X8_CA(0xd3, 0x0e), /* CS1 */
|
||||
// U8X8_CA(0xd3, 0x92), /* CS2 */
|
||||
|
||||
U8X8_CA(0xda, 0x12), /* Set SEG Pins Hardware Configuration: */
|
||||
U8X8_CA(0x81, 0x5a), /* contrast */
|
||||
U8X8_CA(0xd9, 0x22), /* Set Phase Length */
|
||||
U8X8_CA(0xdb, 0x30), /* VCOMH Deselect Level */
|
||||
U8X8_CA(0xad, 0x10), /* Internal IREF Enable */
|
||||
U8X8_CA(0x20, 0x00), /* Memory Addressing Mode: Horizontal */
|
||||
U8X8_CA(0x8d, 0x01), /* disable internal charge pump 1 */
|
||||
U8X8_CA(0xac, 0x00), /* disable internal charge pump 2 */
|
||||
U8X8_C(0xa4), /* display on */
|
||||
U8X8_C(0xa6), /* normal display */
|
||||
|
||||
U8X8_DLY(1), /* delay 2ms */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
/*
|
||||
OLED_WR_Byte(0xae,OLED_CMD);//Display OFF
|
||||
OLED_WR_Byte(0xfd,OLED_CMD);//Set Command Lock
|
||||
OLED_WR_Byte(0x12,OLED_CMD);
|
||||
OLED_WR_Byte(0x20,OLED_CMD);//Set Memory Addressing Mode
|
||||
OLED_WR_Byte(0x00,OLED_CMD);
|
||||
OLED_WR_Byte(0x25,OLED_CMD);//Set Portrait Addressing Mode
|
||||
OLED_WR_Byte(0x00,OLED_CMD);//Normal Addressing Mode
|
||||
OLED_WR_Byte(0x81,OLED_CMD);//Set Contrast Control
|
||||
OLED_WR_Byte(0x6b,OLED_CMD);
|
||||
OLED_WR_Byte1(0xa0,OLED_CMD,1);//Set Seg Remap LEFT DISPLAY
|
||||
OLED_WR_Byte1(0xa1,OLED_CMD,2);//Set Seg Remap RIGHT DISPLAY
|
||||
OLED_WR_Byte(0xa2,OLED_CMD);//Set Display Start Line
|
||||
OLED_WR_Byte(0x00,OLED_CMD);
|
||||
OLED_WR_Byte(0xa4,OLED_CMD);//Resume to RAM content display
|
||||
OLED_WR_Byte(0xa6,OLED_CMD);//Set Normal Display
|
||||
|
||||
OLED_WR_Byte(0xa8,OLED_CMD);//Set MUX Ratio
|
||||
OLED_WR_Byte(0x83,OLED_CMD);//1/132 duty
|
||||
|
||||
OLED_WR_Byte(0xad,OLED_CMD);//Select external or internal IREF
|
||||
OLED_WR_Byte(0x10,OLED_CMD);
|
||||
OLED_WR_Byte(0xbc,OLED_CMD);//Set Pre-charge voltage
|
||||
OLED_WR_Byte(0x1e,OLED_CMD);//
|
||||
OLED_WR_Byte(0xbf,OLED_CMD);//Linear LUT
|
||||
OLED_WR_Byte1(0xc8,OLED_CMD,1);//Set COM Output Scan Direction LEFT DISPLAY
|
||||
OLED_WR_Byte1(0xc0,OLED_CMD,2);//Set COM Output Scan Direction RIGHT DISPLAY
|
||||
OLED_WR_Byte(0xd3,OLED_CMD);//Set Display Offset
|
||||
OLED_WR_Byte1(0x0e,OLED_CMD,1); //LEFT DISPLAY
|
||||
OLED_WR_Byte1(0x92,OLED_CMD,2); // RIGHT DISPLAY
|
||||
OLED_WR_Byte(0xd5,OLED_CMD);//Set Display Clock Divide Ratio/Oscillator Frequency
|
||||
OLED_WR_Byte(0xc2,OLED_CMD);//85Hz
|
||||
OLED_WR_Byte(0xd9,OLED_CMD);//Set Pre-charge Period
|
||||
OLED_WR_Byte(0x72,OLED_CMD);//
|
||||
OLED_WR_Byte(0xda,OLED_CMD);//Set SEG Pins Hardware Configuration
|
||||
OLED_WR_Byte(0x32,OLED_CMD);
|
||||
OLED_WR_Byte(0xbd,OLED_CMD);//Set VP
|
||||
OLED_WR_Byte(0x03,OLED_CMD);
|
||||
OLED_WR_Byte(0xdb,OLED_CMD);//Set VCOMH
|
||||
OLED_WR_Byte(0x30,OLED_CMD);
|
||||
OLED_WR_Byte(0xaf,OLED_CMD);//Display on
|
||||
*/
|
||||
static const uint8_t u8x8_d_ssd1320_160x132_init_seq[] = {
|
||||
U8X8_DLY(1),
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(1),
|
||||
|
||||
U8X8_C(0xae), /* display off */
|
||||
U8X8_CA(0xd5, 0xC2), /* set display clock divide ratio/oscillator frequency (set clock as 80 frames/sec) */
|
||||
U8X8_CA(0xa8, 0x83), /* multiplex ratio 1/132 Duty */
|
||||
U8X8_CA(0xa2, 0x00), /* display start line */
|
||||
|
||||
U8X8_C(0xa0), /* Set Segment Re-Map: column address 0 mapped to SEG0 CS1 */
|
||||
// U8X8_C(0xa1), /* Set Segment Re-Map: column address 0 mapped to SEG0 CS2 */
|
||||
|
||||
U8X8_C(0xc8), /* Set COM Output Scan Direction: normal mode CS1 */
|
||||
// U8X8_C(0xc0), /* Set COM Output Scan Direction: normal mode CS2 */
|
||||
|
||||
U8X8_CA(0xad, 0x10), /* select Iref: 0x00 external (reset default), 0x10 internal */
|
||||
U8X8_CA(0xbc, 0x1e), /* pre-charge voltage level 0x00..0x1f, reset default: 0x1e */
|
||||
U8X8_C(0xbf), /* select linear LUT */
|
||||
U8X8_CA(0xd5, 0xc2), /* Bit 0..3: clock ratio 1, 2, 4, 8, ...256, reset=0x1, Bit 4..7: F_osc 0..15 */
|
||||
U8X8_CA(0xd9, 0x72), /* Set Phase 1&2 Length, Bit 0..3: Phase 1, Bit 4..7: Phase 2, reset default 0x72 */
|
||||
U8X8_CA(0xbd, 0x03), /* from the vendor init sequence */
|
||||
U8X8_CA(0xdb, 0x30), /* VCOMH Deselect Level */
|
||||
|
||||
|
||||
U8X8_CA(0xd3, 0x0e), /* CS1 */
|
||||
// U8X8_CA(0xd3, 0x92), /* CS2 */
|
||||
|
||||
U8X8_CA(0xda, 0x12), /* Set SEG Pins Hardware Configuration: */
|
||||
U8X8_CA(0x81, 0x6b), /* contrast */
|
||||
//U8X8_CA(0xd9, 0x22), /* Set Phase Length */
|
||||
//U8X8_CA(0xdb, 0x30), /* VCOMH Deselect Level */
|
||||
//U8X8_CA(0xad, 0x10), /* Internal IREF Enable */
|
||||
U8X8_CA(0x20, 0x00), /* Memory Addressing Mode: Horizontal */
|
||||
//U8X8_CA(0x8d, 0x01), /* unknown in SSD1320 datasheet, disable internal charge pump 1 */
|
||||
//U8X8_CA(0xac, 0x00), /* unknown in SSD1320 datasheet, disable internal charge pump 2 */
|
||||
U8X8_C(0xa4), /* display RAM on */
|
||||
U8X8_C(0xa6), /* normal display */
|
||||
|
||||
U8X8_DLY(1), /* delay 2ms */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1320_160x132(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_d_ssd1320_cs1_160x132_display_info);
|
||||
|
||||
break;
|
||||
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
// u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1320_cs1_160x132_init_seq);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1320_160x132_init_seq);
|
||||
break;
|
||||
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 ){
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1320_cs1_160x132_nhd_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1320_cs1_160x132_nhd_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return u8x8_d_ssd1320_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ static const u8x8_display_info_t u8x8_ssd1322_256x64_display_info =
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1322: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1322: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215), 10 MHz (issue 301) */
|
||||
/* sck_clock_hz = */ 10000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215), 10 MHz (issue 301) */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 10,
|
||||
@@ -259,7 +259,7 @@ static const u8x8_display_info_t u8x8_ssd1322_256x64_display_info =
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0x01c, /* this is the byte offset (there are two pixel per byte with 4 bit per pixel) */
|
||||
/* flipmode_x_offset = */ 0x01c,
|
||||
/* pixel_width = */ 270,
|
||||
/* pixel_width = */ 256,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
@@ -272,20 +272,20 @@ static const uint8_t u8x8_d_ssd1322_256x64_init_seq[] = {
|
||||
|
||||
U8X8_CA(0xfd, 0x12), /* unlock */
|
||||
U8X8_C(0xae), /* display off */
|
||||
U8X8_CA(0xb3, 0xB2), /* set display clock divide ratio/oscillator frequency (set clock as 80 frames/sec) */
|
||||
U8X8_CA(0xb3, 0x91), /* set display clock divide ratio/oscillator frequency (set clock as 80 frames/sec) */
|
||||
U8X8_CA(0xca, 0x3f), /* multiplex ratio 1/64 Duty (0x0F~0x3F) */
|
||||
U8X8_CA(0xa2, 0x00), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0xa1, 0x00), /* display start line */
|
||||
//U8X8_CAA(0xa0, 0x14, 0x11), /* Set Re-Map / Dual COM Line Mode */
|
||||
U8X8_CAA(0xa0, 0x06, 0x011), /* Set Re-Map / Dual COM Line Mode */
|
||||
U8X8_CA(0xab, 0x01), /* Enable Internal VDD Regulator */
|
||||
U8X8_CAA(0xb4, 0xa0, 0xB5), /* Display Enhancement A */
|
||||
U8X8_CAA(0xb4, 0xa0, 0x005|0x0fd), /* Display Enhancement A */
|
||||
U8X8_CA(0xc1, 0x9f), /* contrast */
|
||||
U8X8_CA(0xc7, 0x0f), /* Set Scale Factor of Segment Output Current Control */
|
||||
U8X8_C(0xb9), /* linear grayscale */
|
||||
U8X8_CA(0xb1, 0xe3), /* Phase 1 (Reset) & Phase 2 (Pre-Charge) Period Adjustment */
|
||||
U8X8_CA(0xb1, 0xe2), /* Phase 1 (Reset) & Phase 2 (Pre-Charge) Period Adjustment */
|
||||
U8X8_CAA(0xd1, 0x082|0x020, 0x020), /* Display Enhancement B */
|
||||
U8X8_CA(0xbb, 0x0f), /* precharge voltage */
|
||||
U8X8_CA(0xbb, 0x1f), /* precharge voltage */
|
||||
U8X8_CA(0xb6, 0x08), /* precharge period */
|
||||
U8X8_CA(0xbe, 0x07), /* vcomh */
|
||||
U8X8_C(0xa6), /* normal display */
|
||||
|
||||
435
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1325.c
Normal file
435
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1325.c
Normal file
@@ -0,0 +1,435 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1325.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SSD1325:
|
||||
128 x 80, 16 Gray Scale Dot Matrix
|
||||
|
||||
SSD0323: Identical to SSD1325, issue 720
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1325_128x64_nhd_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1325_128x64_nhd_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1325_128x64_nhd_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a0, 0x052), /* remap */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1325_128x64_nhd_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a0, 0x041), /* remap */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
input:
|
||||
one tile (8 Bytes)
|
||||
output:
|
||||
Tile for SSD1325 (32 Bytes)
|
||||
*/
|
||||
|
||||
static uint8_t u8x8_ssd1325_8to32_dest_buf[32];
|
||||
|
||||
static uint8_t *u8x8_ssd1325_8to32(U8X8_UNUSED u8x8_t *u8x8, uint8_t *ptr)
|
||||
{
|
||||
uint8_t v;
|
||||
uint8_t a,b;
|
||||
uint8_t i, j;
|
||||
uint8_t *dest;
|
||||
|
||||
for( j = 0; j < 4; j++ )
|
||||
{
|
||||
dest = u8x8_ssd1325_8to32_dest_buf;
|
||||
dest += j;
|
||||
a =*ptr;
|
||||
ptr++;
|
||||
b = *ptr;
|
||||
ptr++;
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
v = 0;
|
||||
if ( a&1 ) v |= 0xf0;
|
||||
if ( b&1 ) v |= 0x0f;
|
||||
*dest = v;
|
||||
dest+=4;
|
||||
a >>= 1;
|
||||
b >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return u8x8_ssd1325_8to32_dest_buf;
|
||||
}
|
||||
|
||||
|
||||
/*===================================================================*/
|
||||
|
||||
static uint8_t u8x8_d_ssd1325_128x64_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1325_128x64_nhd_display_info);
|
||||
break;
|
||||
*/
|
||||
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1325_128x64_nhd_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1325_128x64_nhd_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1325_128x64_nhd_powersave1_seq);
|
||||
break;
|
||||
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1325_128x64_nhd_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1325_128x64_nhd_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
*/
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1325 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 4;
|
||||
|
||||
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
y *= 8;
|
||||
y += u8x8->x_offset; /* x_offset is used as y offset for the SSD1325 */
|
||||
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x075 ); /* set row address */
|
||||
u8x8_cad_SendArg(u8x8, y);
|
||||
u8x8_cad_SendArg(u8x8, y+7);
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
|
||||
do
|
||||
{
|
||||
if ( ptr[0] | ptr[1] | ptr[2] | ptr[3] | ptr[4] | ptr[5] | ptr[6] | ptr[7] )
|
||||
{
|
||||
/* draw the tile if pattern is not zero for all bytes */
|
||||
u8x8_cad_SendCmd(u8x8, 0x015 ); /* set column address */
|
||||
u8x8_cad_SendArg(u8x8, x ); /* start */
|
||||
u8x8_cad_SendArg(u8x8, x+3 ); /* end */
|
||||
|
||||
|
||||
|
||||
u8x8_cad_SendData(u8x8, 32, u8x8_ssd1325_8to32(u8x8, ptr));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* tile is empty, use the graphics acceleration command */
|
||||
u8x8_cad_SendCmd(u8x8, 0x024 ); // draw rectangle
|
||||
u8x8_cad_SendArg(u8x8, x );
|
||||
u8x8_cad_SendArg(u8x8, y );
|
||||
u8x8_cad_SendArg(u8x8, x+3 );
|
||||
u8x8_cad_SendArg(u8x8, y+7 );
|
||||
u8x8_cad_SendArg(u8x8, 0 ); // clear
|
||||
}
|
||||
ptr += 8;
|
||||
x += 4;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
|
||||
//x += 4;
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0xe3); // no-op needs to be sent after last byte before cs is toggled.
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*===================================================================*/
|
||||
|
||||
/* http://www.newhavendisplay.com/app_notes/OLED_2_7_12864.txt */
|
||||
static const uint8_t u8x8_d_ssd1325_128x64_nhd_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0b3, 0x091), /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
|
||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio: 0x03f * 1/64 duty */
|
||||
U8X8_CA(0x0a2, 0x04c), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a1, 0x000), /* display start line */
|
||||
U8X8_CA(0x0ad, 0x002), /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
U8X8_CA(0x0a0, 0x052), /* remap configuration, horizontal address increment (bit 2 = 0), enable nibble remap (upper nibble is left, bit 1 = 1) */
|
||||
U8X8_C(0x086), /* full current range (0x084, 0x085, 0x086) */
|
||||
U8X8_C(0x0b8), /* set gray scale table */
|
||||
U8X8_A(0x001), /* */
|
||||
U8X8_A(0x011), /* */
|
||||
U8X8_A(0x022), /* */
|
||||
U8X8_A(0x032), /* */
|
||||
U8X8_A(0x043), /* */
|
||||
U8X8_A(0x054), /* */
|
||||
U8X8_A(0x065), /* */
|
||||
U8X8_A(0x076), /* */
|
||||
|
||||
U8X8_CA(0x081, 0x070), /* contrast, brightness, 0..128, Newhaven: 0x040 */
|
||||
U8X8_CA(0x0b2, 0x051), /* frame frequency (row period) */
|
||||
U8X8_CA(0x0b1, 0x055), /* phase length */
|
||||
U8X8_CA(0x0bc, 0x010), /* pre-charge voltage level */
|
||||
U8X8_CA(0x0b4, 0x002), /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
U8X8_CA(0x0b0, 0x028), /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
U8X8_CA(0x0be, 0x01c), /* VCOMH voltage */
|
||||
U8X8_CA(0x0bf, 0x002|0x00d), /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
U8X8_C(0x0a4), /* normal display mode */
|
||||
|
||||
U8X8_CA(0x023, 0x003), /* graphics accelleration: fill pixel */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const u8x8_display_info_t u8x8_nhd_ssd1325_128x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100, /**/
|
||||
/* sda_setup_time_ns = */ 100, /* SSD1325 */
|
||||
/* sck_pulse_width_ns = */ 100, /* SSD1325 */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 60, /* SSD1325 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0, /* x_offset is used as y offset for the SSD1325 */
|
||||
/* flipmode_x_offset = */ 8, /* x_offset is used as y offset for the SSD1325 */
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1325_nhd_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_nhd_ssd1325_128x64_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1325_128x64_nhd_init_seq);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE )
|
||||
{
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1325_128x64_nhd_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1325_128x64_nhd_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1325_128x64_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
/*===================================================================*/
|
||||
/* OSRAM Pictiva 128x64 OLED */
|
||||
/* https://github.com/olikraus/u8g2/issues/720 */
|
||||
|
||||
static const uint8_t u8x8_d_ssd0323_os128064_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0b3, 0x091), /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
|
||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio: 0x03f * 1/64 duty */
|
||||
U8X8_CA(0x0a2, 0x040), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a1, 0x000), /* display start line */
|
||||
U8X8_CA(0x0ad, 0x002), /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
U8X8_CA(0x0a0, 0x052), /* remap configuration, horizontal address increment (bit 2 = 0), enable nibble remap (upper nibble is left, bit 1 = 1) */
|
||||
U8X8_C(0x086), /* full current range (0x084, 0x085, 0x086) */
|
||||
U8X8_C(0x0b8), /* set gray scale table */
|
||||
U8X8_A(0x001), /* */
|
||||
U8X8_A(0x011), /* */
|
||||
U8X8_A(0x022), /* */
|
||||
U8X8_A(0x032), /* */
|
||||
U8X8_A(0x043), /* */
|
||||
U8X8_A(0x054), /* */
|
||||
U8X8_A(0x065), /* */
|
||||
U8X8_A(0x076), /* */
|
||||
|
||||
U8X8_CA(0x081, 0x070), /* contrast, brightness, 0..128, Newhaven: 0x040 */
|
||||
U8X8_CA(0x0b2, 0x051), /* frame frequency (row period) */
|
||||
U8X8_CA(0x0b1, 0x055), /* phase length */
|
||||
U8X8_CA(0x0bc, 0x010), /* pre-charge voltage level */
|
||||
U8X8_CA(0x0b4, 0x002), /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
U8X8_CA(0x0b0, 0x028), /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
U8X8_CA(0x0be, 0x01c), /* VCOMH voltage */
|
||||
U8X8_CA(0x0bf, 0x002|0x00d), /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
U8X8_C(0x0a4), /* normal display mode */
|
||||
|
||||
U8X8_CA(0x023, 0x003), /* graphics accelleration: fill pixel */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd0323_os128064_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a0, 0x052), /* remap */
|
||||
U8X8_CA(0x0a2, 0x040), /* display offset, shift mapping ram counter */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd0323_os128064_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a0, 0x041), /* remap */
|
||||
U8X8_CA(0x0a2, 0x050), /* display offset, shift mapping ram counter */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd0323_os128064_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100, /**/
|
||||
/* sda_setup_time_ns = */ 100, /* SSD1325 */
|
||||
/* sck_pulse_width_ns = */ 100, /* SSD1325 */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 60, /* SSD1325 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0, /* x_offset is used as y offset for the SSD1325 */
|
||||
/* flipmode_x_offset = */ 0, /* x_offset is used as y offset for the SSD1325 */
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd0323_os128064(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd0323_os128064_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd0323_os128064_init_seq);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE )
|
||||
{
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd0323_os128064_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd0323_os128064_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1325_128x64_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
277
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1326.c
Normal file
277
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1326.c
Normal file
@@ -0,0 +1,277 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1326.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
/* ER OLED */
|
||||
static const uint8_t u8x8_d_ssd1326_er_256x32_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_CA(0x0fd, 0x012), /* unlock (not required, this is default by reset) */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0a8, 0x01f), /* multiplex ratio: 0x03f * 1/64 duty - changed by CREESOO, acc. to datasheet, 100317*/
|
||||
U8X8_CA(0x0a1, 0x000), /* display start line */
|
||||
U8X8_CA(0x0a2, 0x000), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0ad, 0x002), /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
/*
|
||||
a0 command: 0x0a0 ***abcde
|
||||
a: 1: mono mode
|
||||
b: 0: horizontal (1: vertical) address increment
|
||||
c: 1: enable bit remap
|
||||
d: 1: COM remap
|
||||
e: 1: Column remap
|
||||
*/
|
||||
U8X8_CA(0x0a0, 0x006), /* remap configuration, see above */
|
||||
U8X8_C(0x086), /* full current range (0x084, 0x085, 0x086) */
|
||||
|
||||
U8X8_C(0x0b7), /* set default gray scale table */
|
||||
|
||||
U8X8_CA(0x081, 0x027), /* contrast, brightness, 0..128 */
|
||||
U8X8_CA(0x0b1, 0x071), /* phase length */
|
||||
//U8X8_CA(0x0b2, 0x051), /* frame frequency (row period) */
|
||||
U8X8_CA(0x0b3, 0x0f0), /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
|
||||
//U8X8_CA(0x0b4, 0x002), /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
//U8X8_CA(0x0b0, 0x028), /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
U8X8_CAA(0x0bb, 0x035, 0x0ff), /* set precharge */
|
||||
U8X8_CA(0x0bc, 0x01f), /* pre-charge voltage level */
|
||||
U8X8_CA(0x0be, 0x00f), /* VCOMH voltage */
|
||||
U8X8_CA(0x0bf, 0x002|0x00d), /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
U8X8_C(0x0a4), /* normal display mode */
|
||||
|
||||
//U8X8_CA(0x023, 0x003), /* graphics accelleration: fill pixel */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1326_256x32_nhd_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1326_256x32_nhd_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1326_256x32_nhd_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a0, 0x006), /* remap 00110 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1326_256x32_nhd_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
//U8X8_CA(0x0a0, 0x005), /* remap 00101 */
|
||||
U8X8_CA(0x0a0, 0x001), /* remap 00001 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
input:
|
||||
one tile (8 Bytes)
|
||||
output:
|
||||
Tile for ssd1326 (32 Bytes)
|
||||
*/
|
||||
|
||||
static uint8_t u8x8_ssd1326_8to32_dest_buf[32];
|
||||
|
||||
static uint8_t *u8x8_ssd1326_8to32(U8X8_UNUSED u8x8_t *u8x8, uint8_t *ptr)
|
||||
{
|
||||
uint8_t v;
|
||||
uint8_t a,b;
|
||||
uint8_t i, j;
|
||||
uint8_t *dest;
|
||||
|
||||
for( j = 0; j < 4; j++ )
|
||||
{
|
||||
dest = u8x8_ssd1326_8to32_dest_buf;
|
||||
dest += j;
|
||||
a =*ptr;
|
||||
ptr++;
|
||||
b = *ptr;
|
||||
ptr++;
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
v = 0;
|
||||
if ( a&1 ) v |= 0xf0;
|
||||
if ( b&1 ) v |= 0x0f;
|
||||
*dest = v;
|
||||
dest+=4;
|
||||
a >>= 1;
|
||||
b >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return u8x8_ssd1326_8to32_dest_buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1326_256x32_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1326_256x32_nhd_display_info);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1326_er_256x32_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1326_256x32_nhd_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1326_256x32_nhd_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1326_256x32_nhd_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1326_256x32_nhd_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1326 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 4;
|
||||
|
||||
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
|
||||
y *= 8;
|
||||
y += u8x8->x_offset; /* x_offset is used as y offset for the ssd1326 */
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendCmd(u8x8, 0x015 ); /* set column address */
|
||||
u8x8_cad_SendArg(u8x8, x ); /* start */
|
||||
u8x8_cad_SendArg(u8x8, x+3 ); /* end */
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x075 ); /* set row address */
|
||||
u8x8_cad_SendArg(u8x8, y);
|
||||
u8x8_cad_SendArg(u8x8, y+7);
|
||||
|
||||
u8x8_cad_SendData(u8x8, 32, u8x8_ssd1326_8to32(u8x8, ptr));
|
||||
|
||||
ptr += 8;
|
||||
x += 4;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
|
||||
//x += 4;
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1326_256x32_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 15,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100, /**/
|
||||
/* sda_setup_time_ns = */ 100, /* ssd1326 */
|
||||
/* sck_pulse_width_ns = */ 100, /* ssd1326 */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 60, /* ssd1326 */
|
||||
/* tile_width = */ 32,
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 0, /* x_offset is used as y offset for the ssd1326 */
|
||||
/* flipmode_x_offset = */ 0, /* x_offset is used as y offset for the ssd1326 */
|
||||
/* pixel_width = */ 256,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1326_er_256x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1326_256x32_display_info);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1326_256x32_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
952
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1327.c
Normal file
952
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1327.c
Normal file
@@ -0,0 +1,952 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1327.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1327_96x96_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1327_96x96_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1327_seeed_96x96_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a2, 0x020), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a0, 0x051), /* remap configuration */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1327_seeed_96x96_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a2, 0x060), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a0, 0x042), /* remap configuration */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1327_winstar_96x64_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a0, 0x042), /* remap configuration */
|
||||
U8X8_CA(0x0a2, 0x000), /* display offset, shift mapping ram counter */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1327_winstar_96x64_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a0, 0x051), /* remap configuration */
|
||||
U8X8_CA(0x0a2, 0x040), /* display offset, shift mapping ram counter */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
/*
|
||||
input:
|
||||
one tile (8 Bytes)
|
||||
output:
|
||||
Tile for ssd1327 (32 Bytes)
|
||||
*/
|
||||
|
||||
static uint8_t u8x8_ssd1327_8to32_dest_buf[32];
|
||||
|
||||
static uint8_t *u8x8_ssd1327_8to32(U8X8_UNUSED u8x8_t *u8x8, uint8_t *ptr)
|
||||
{
|
||||
uint8_t v;
|
||||
uint8_t a,b;
|
||||
uint8_t i, j;
|
||||
uint8_t *dest;
|
||||
|
||||
for( j = 0; j < 4; j++ )
|
||||
{
|
||||
dest = u8x8_ssd1327_8to32_dest_buf;
|
||||
dest += j;
|
||||
a =*ptr;
|
||||
ptr++;
|
||||
b = *ptr;
|
||||
ptr++;
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
v = 0;
|
||||
if ( a&1 ) v |= 0xf0;
|
||||
if ( b&1 ) v |= 0x0f;
|
||||
*dest = v;
|
||||
dest+=4;
|
||||
a >>= 1;
|
||||
b >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return u8x8_ssd1327_8to32_dest_buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1327_96x96_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1327_96x96_display_info);
|
||||
break;
|
||||
*/
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_96x96_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_96x96_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_96x96_powersave1_seq);
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1327 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 4;
|
||||
x+=u8x8->x_offset/2;
|
||||
|
||||
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
y *= 8;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x075 ); /* set row address, moved out of the loop (issue 302) */
|
||||
u8x8_cad_SendArg(u8x8, y);
|
||||
u8x8_cad_SendArg(u8x8, y+7);
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendCmd(u8x8, 0x015 ); /* set column address */
|
||||
u8x8_cad_SendArg(u8x8, x ); /* start */
|
||||
u8x8_cad_SendArg(u8x8, x+3 ); /* end */
|
||||
|
||||
|
||||
u8x8_cad_SendData(u8x8, 32, u8x8_ssd1327_8to32(u8x8, ptr));
|
||||
ptr += 8;
|
||||
x += 4;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
|
||||
//x += 4;
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*=============================================*/
|
||||
/*
|
||||
Winstar WEA009664B 96x64 OLED Display, 1.1 inch OLED
|
||||
https://www.winstar.com.tw/products/oled-module/graphic-oled-display/96x64-oled.html
|
||||
|
||||
https://github.com/olikraus/u8g2/issues/1050
|
||||
*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1327_winstar_96x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100, /**/
|
||||
/* sda_setup_time_ns = */ 100, /* */
|
||||
/* sck_pulse_width_ns = */ 100, /* */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 1, /* use 1 instead of 4, because the SSD1327 seems to be very slow */
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 60,
|
||||
/* tile_width = */ 12,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 16, /* changed to 16, issue 1050 */
|
||||
/* flipmode_x_offset = */ 16, /* changed to 16, issue 1050 */
|
||||
/* pixel_width = */ 96,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
/*
|
||||
Write_Cmd(0xAE); //Set Display Off OK
|
||||
Write_Cmd(0x81); //Contrast Level OK
|
||||
Write_Cmd(0xdF); // VALUE WRONG????
|
||||
Write_Cmd(0xD9); //Pre-charge Period
|
||||
Write_Cmd(0x00);
|
||||
Write_Cmd(0xA0); //Set Re-map OK
|
||||
Write_Cmd(0x42); //Default Setting OK
|
||||
Write_Cmd(0xA1); //Set Display Start Line OK
|
||||
Write_Cmd(0x00); OK
|
||||
Write_Cmd(0xA2); //Set Display Offset OK
|
||||
Write_Cmd(0x00); OK
|
||||
Write_Cmd(0xA4); //Set Display Mode OK
|
||||
Write_Cmd(0xA8); //Set Multiplex Ratio OK
|
||||
Write_Cmd(0x63); //Multiplex OK
|
||||
Write_Cmd(0xAB); //Set Function SelectionA OK
|
||||
Write_Cmd(0x01); OK
|
||||
Write_Cmd(0xB1); //Set Phase Length OK
|
||||
Write_Cmd(0x47); OK
|
||||
Write_Cmd(0xB3); //Set Display Clock Divide Ratio/Oscillator Frequency OK
|
||||
Write_Cmd(0x00); OK
|
||||
Write_Cmd(0xBC); //Set Prechange Voltage OK
|
||||
Write_Cmd(0x07); OK
|
||||
Write_Cmd(0xBE); //Set VCOMH Voltage OK
|
||||
Write_Cmd(0x07); OK
|
||||
Write_Cmd(0xB6); //Set Second Pre-charge period OK
|
||||
Write_Cmd(0x04); OK
|
||||
Write_Cmd(0xD5); //Set Function selection B OK
|
||||
Write_Cmd(0x62); OK
|
||||
Write_Cmd(0xAF); //Set Display On
|
||||
|
||||
*/
|
||||
|
||||
static const uint8_t u8x8_d_ssd1327_winstar_96x64_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_CA(0x0fd, 0x012), /* unlock display, usually not required because the display is unlocked after reset */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
|
||||
U8X8_CA(0x0d9, 0x000), /* Pre-charge Period ??? */
|
||||
|
||||
U8X8_CA(0x0a0, 0x042), /* remap configuration */
|
||||
U8X8_CA(0x0a1, 0x000), /* display start line */
|
||||
U8X8_CA(0x0a2, 0x000), /* display offset, shift mapping ram counter */
|
||||
|
||||
U8X8_CA(0x0a8, 0x063), /* multiplex ratio: 63* 1/64 duty */ /* changed to hex, issue 1050 */
|
||||
|
||||
U8X8_CA(0x0ab, 0x001), /* Enable internal VDD regulator (RESET) */
|
||||
U8X8_CA(0x081, 0x053), /* contrast, brightness, 0..128 */
|
||||
|
||||
U8X8_CA(0x0b1, 0x047), /* phase length */
|
||||
//U8X8_CA(0x0b3, 0x001), /* set display clock divide ratio/oscillator frequency */
|
||||
U8X8_CA(0x0b3, 0x000), /* set display clock divide ratio/oscillator frequency */
|
||||
|
||||
U8X8_C(0x0b9), /* use linear lookup table */
|
||||
|
||||
U8X8_CA(0x0bc, 0x007), /* pre-charge voltage level */
|
||||
U8X8_CA(0x0be, 0x007), /* VCOMH voltage */
|
||||
U8X8_CA(0x0b6, 0x004), /* second precharge */
|
||||
U8X8_CA(0x0d5, 0x062), /* enable second precharge, internal vsl (bit0 = 0) */
|
||||
|
||||
U8X8_C(0x0a4), /* normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1327_ws_96x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( u8x8_d_ssd1327_96x96_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1327_winstar_96x64_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_winstar_96x64_init_seq);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE )
|
||||
{
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_winstar_96x64_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_winstar_96x64_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*=============================================*/
|
||||
/* Seeedstudio Grove OLED 96x96 */
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1327_96x96_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100, /**/
|
||||
/* sda_setup_time_ns = */ 100, /* */
|
||||
/* sck_pulse_width_ns = */ 100, /* */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 1, /* use 1 instead of 4, because the SSD1327 seems to be very slow */
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 60,
|
||||
/* tile_width = */ 12,
|
||||
/* tile_hight = */ 12,
|
||||
/* default_x_offset = */ 16,
|
||||
/* flipmode_x_offset = */ 16,
|
||||
/* pixel_width = */ 96,
|
||||
/* pixel_height = */ 96
|
||||
};
|
||||
|
||||
/* https://github.com/SeeedDocument/Grove_OLED_1.12/raw/master/resources/LY120-096096.pdf */
|
||||
/* http://www.seeedstudio.com/wiki/index.php?title=Twig_-_OLED_96x96 */
|
||||
/* values from u8glib */
|
||||
/*
|
||||
Re-map setting in Graphic Display Data RAM, command 0x0a0
|
||||
Bit 0: Column Address Re-map
|
||||
Bit 1: Nibble Re-map
|
||||
Bit 2: Horizontal/Vertical Address Increment
|
||||
Bit 3: Not used, must be 0
|
||||
|
||||
Bit 4: COM Re-map
|
||||
Bit 5: Not used, must be 0
|
||||
Bit 6: COM Split Odd Even
|
||||
Bit 7: Not used, must be 0
|
||||
*/
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1327_96x96_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_CA(0x0fd, 0x012), /* unlock display, usually not required because the display is unlocked after reset */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
//U8X8_CA(0x0a8, 0x03f), /* multiplex ratio: 0x03f * 1/64 duty */
|
||||
U8X8_CA(0x0a8, 0x05f), /* multiplex ratio: 0x05f * 1/64 duty */
|
||||
U8X8_CA(0x0a1, 0x000), /* display start line */
|
||||
//U8X8_CA(0x0a2, 0x04c), /* display offset, shift mapping ram counter */
|
||||
|
||||
U8X8_CA(0x0a2, 0x020), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a0, 0x051), /* remap configuration */
|
||||
|
||||
|
||||
U8X8_CA(0x0ab, 0x001), /* Enable internal VDD regulator (RESET) */
|
||||
//U8X8_CA(0x081, 0x070), /* contrast, brightness, 0..128 */
|
||||
U8X8_CA(0x081, 0x053), /* contrast, brightness, 0..128 */
|
||||
//U8X8_CA(0x0b1, 0x055), /* phase length */
|
||||
U8X8_CA(0x0b1, 0x051), /* phase length */
|
||||
//U8X8_CA(0x0b3, 0x091), /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
|
||||
U8X8_CA(0x0b3, 0x001), /* set display clock divide ratio/oscillator frequency */
|
||||
|
||||
//? U8X8_CA(0x0ad, 0x002), /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
//? U8X8_C(0x086), /* full current range (0x084, 0x085, 0x086) */
|
||||
|
||||
U8X8_C(0x0b9), /* use linear lookup table */
|
||||
|
||||
//U8X8_CA(0x0bc, 0x010), /* pre-charge voltage level */
|
||||
U8X8_CA(0x0bc, 0x008), /* pre-charge voltage level */
|
||||
//U8X8_CA(0x0be, 0x01c), /* VCOMH voltage */
|
||||
U8X8_CA(0x0be, 0x007), /* VCOMH voltage */
|
||||
U8X8_CA(0x0b6, 0x001), /* second precharge */
|
||||
U8X8_CA(0x0d5, 0x062), /* enable second precharge, internal vsl (bit0 = 0) */
|
||||
|
||||
|
||||
|
||||
U8X8_C(0x0a4), /* normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
uint8_t u8x8_d_ssd1327_seeed_96x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( u8x8_d_ssd1327_96x96_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1327_96x96_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_96x96_init_seq);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE )
|
||||
{
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_seeed_96x96_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_seeed_96x96_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*=============================================*/
|
||||
/* EA W128128 round OLED 128x128 */
|
||||
/* issue #641 */
|
||||
/* https://www.lcd-module.de/fileadmin/eng/pdf/grafik/W128128-XR.pdf */
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1327_ea_w128128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100, /**/
|
||||
/* sda_setup_time_ns = */ 100, /* */
|
||||
/* sck_pulse_width_ns = */ 100, /* */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 1, /* use 1 instead of 4, because the SSD1327 seems to be very slow */
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 60,
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
/* this is a copy of the init sequence for the seeed 96x96 oled */
|
||||
static const uint8_t u8x8_d_ssd1327_ea_w128128_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_CA(0x0fd, 0x012), /* unlock display, usually not required because the display is unlocked after reset */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
//U8X8_CA(0x0a8, 0x03f), /* multiplex ratio: 0x03f * 1/64 duty */
|
||||
U8X8_CA(0x0a8, 0x05f), /* multiplex ratio: 0x05f * 1/64 duty */
|
||||
U8X8_CA(0x0a1, 0x000), /* display start line */
|
||||
//U8X8_CA(0x0a2, 0x04c), /* display offset, shift mapping ram counter */
|
||||
|
||||
U8X8_CA(0x0a2, 0x010), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a0, 0x051), /* remap configuration */
|
||||
|
||||
|
||||
U8X8_CA(0x0ab, 0x001), /* Enable internal VDD regulator (RESET) */
|
||||
//U8X8_CA(0x081, 0x070), /* contrast, brightness, 0..128 */
|
||||
U8X8_CA(0x081, 0x053), /* contrast, brightness, 0..128 */
|
||||
//U8X8_CA(0x0b1, 0x055), /* phase length */
|
||||
U8X8_CA(0x0b1, 0x051), /* phase length */
|
||||
//U8X8_CA(0x0b3, 0x091), /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
|
||||
U8X8_CA(0x0b3, 0x001), /* set display clock divide ratio/oscillator frequency */
|
||||
|
||||
//? U8X8_CA(0x0ad, 0x002), /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
//? U8X8_C(0x086), /* full current range (0x084, 0x085, 0x086) */
|
||||
|
||||
U8X8_C(0x0b9), /* use linear lookup table */
|
||||
|
||||
//U8X8_CA(0x0bc, 0x010), /* pre-charge voltage level */
|
||||
U8X8_CA(0x0bc, 0x008), /* pre-charge voltage level */
|
||||
//U8X8_CA(0x0be, 0x01c), /* VCOMH voltage */
|
||||
U8X8_CA(0x0be, 0x007), /* VCOMH voltage */
|
||||
U8X8_CA(0x0b6, 0x001), /* second precharge */
|
||||
U8X8_CA(0x0d5, 0x062), /* enable second precharge, internal vsl (bit0 = 0) */
|
||||
|
||||
U8X8_C(0x0a4), /* normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1327_ea_w128128_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a2, 0x000), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a0, 0x051), /* remap configuration */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1327_ea_w128128_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a2, 0x000), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a0, 0x042), /* remap configuration */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1327_ea_w128128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( u8x8_d_ssd1327_96x96_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1327_ea_w128128_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_ea_w128128_init_seq);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE )
|
||||
{
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_ea_w128128_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_ea_w128128_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*=============================================*/
|
||||
/* MIDAS MCOT128128C1V-YM 128x128 Module */
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1327_128x128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100, /**/
|
||||
/* sda_setup_time_ns = */ 100, /* */
|
||||
/* sck_pulse_width_ns = */ 100, /* */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 1, /* use 1 instead of 4, because the SSD1327 seems to be very slow, Update 9 Aug 2019: The OLED from aliexpress supports 400kHz */
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 60,
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
/* https://github.com/SeeedDocument/Grove_OLED_1.12/raw/master/resources/LY120-096096.pdf */
|
||||
/* http://www.seeedstudio.com/wiki/index.php?title=Twig_-_OLED_96x96 */
|
||||
/* values from u8glib */
|
||||
/*
|
||||
Re-map setting in Graphic Display Data RAM, command 0x0a0
|
||||
Bit 0: Column Address Re-map
|
||||
Bit 1: Nibble Re-map
|
||||
Bit 2: Horizontal/Vertical Address Increment
|
||||
Bit 3: Not used, must be 0
|
||||
|
||||
Bit 4: COM Re-map
|
||||
Bit 5: Not used, must be 0
|
||||
Bit 6: COM Split Odd Even
|
||||
Bit 7: Not used, must be 0
|
||||
*/
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1327_128x128_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_CA(0x0fd, 0x012), /* unlock display, usually not required because the display is unlocked after reset */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
//U8X8_CA(0x0a8, 0x03f), /* multiplex ratio: 0x03f * 1/64 duty */
|
||||
//U8X8_CA(0x0a8, 0x05f), /* multiplex ratio: 0x05f * 1/64 duty */
|
||||
U8X8_CA(0x0a8, 0x07f), /* multiplex ratio: 0x05f * 1/128duty */
|
||||
U8X8_CA(0x0a1, 0x000), /* display start line */
|
||||
//U8X8_CA(0x0a2, 0x04c), /* display offset, shift mapping ram counter */
|
||||
|
||||
U8X8_CA(0x0a2, 0x000), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a0, 0x051), /* remap configuration */
|
||||
|
||||
|
||||
U8X8_CA(0x0ab, 0x001), /* Enable internal VDD regulator (RESET) */
|
||||
//U8X8_CA(0x081, 0x070), /* contrast, brightness, 0..128 */
|
||||
U8X8_CA(0x081, 0x053), /* contrast, brightness, 0..128 */
|
||||
//U8X8_CA(0x0b1, 0x055), /* phase length */
|
||||
U8X8_CA(0x0b1, 0x051), /* phase length */
|
||||
//U8X8_CA(0x0b3, 0x091), /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
|
||||
U8X8_CA(0x0b3, 0x001), /* set display clock divide ratio/oscillator frequency */
|
||||
|
||||
//? U8X8_CA(0x0ad, 0x002), /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
//? U8X8_C(0x086), /* full current range (0x084, 0x085, 0x086) */
|
||||
|
||||
U8X8_C(0x0b9), /* use linear lookup table */
|
||||
|
||||
//U8X8_CA(0x0bc, 0x010), /* pre-charge voltage level */
|
||||
U8X8_CA(0x0bc, 0x008), /* pre-charge voltage level */
|
||||
//U8X8_CA(0x0be, 0x01c), /* VCOMH voltage */
|
||||
U8X8_CA(0x0be, 0x007), /* VCOMH voltage */
|
||||
U8X8_CA(0x0b6, 0x001), /* second precharge */
|
||||
U8X8_CA(0x0d5, 0x062), /* enable second precharge, internal vsl (bit0 = 0) */
|
||||
|
||||
|
||||
|
||||
U8X8_C(0x0a4), /* normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1327_128x128_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a2, 0x000), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a0, 0x051), /* remap configuration */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1327_128x128_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a2, 0x000), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a0, 0x042), /* remap configuration */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_ssd1327_midas_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call the 96x96 procedure at the moment */
|
||||
if ( u8x8_d_ssd1327_96x96_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1327_128x128_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_128x128_init_seq);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE )
|
||||
{
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_128x128_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_128x128_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*=============================================*/
|
||||
/*
|
||||
Waveshare 128x128 Module
|
||||
https://www.waveshare.com/w/upload/8/80/1.5inch_OLED_Module_User_Manual_EN.pdf
|
||||
https://github.com/olikraus/u8g2/issues/880
|
||||
|
||||
This is mostly a takeover of the EA display.
|
||||
*/
|
||||
|
||||
/* https://github.com/SeeedDocument/Grove_OLED_1.12/raw/master/resources/LY120-096096.pdf */
|
||||
/* http://www.seeedstudio.com/wiki/index.php?title=Twig_-_OLED_96x96 */
|
||||
/* values from u8glib */
|
||||
/*
|
||||
Re-map setting in Graphic Display Data RAM, command 0x0a0
|
||||
Bit 0: Column Address Re-map
|
||||
Bit 1: Nibble Re-map
|
||||
Bit 2: Horizontal/Vertical Address Increment
|
||||
Bit 3: Not used, must be 0
|
||||
|
||||
Bit 4: COM Re-map
|
||||
Bit 5: Not used, must be 0
|
||||
Bit 6: COM Split Odd Even
|
||||
Bit 7: Not used, must be 0
|
||||
*/
|
||||
|
||||
/* takeover from https://github.com/olikraus/u8g2/issues/880 */
|
||||
static const uint8_t u8x8_d_ssd1327_ws_128x128_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0ae), //--turn off oled panel
|
||||
U8X8_CAA(0x015, 0x000, 0x07f), //set column address, start column 0, end column 127
|
||||
U8X8_CAA(0x075, 0x000, 0x07f), //set row address, start row 0, end row 127
|
||||
U8X8_CA(0x081, 0x080), //set contrast control
|
||||
U8X8_CA(0x0a0, 0x051), //gment remap, 51
|
||||
U8X8_CA(0x0a1, 0x000), //start line
|
||||
U8X8_CA(0x0a2, 0x000), //display offset
|
||||
U8X8_CAA(0x0a4, 0x0a8, 0x07f), //rmal display, set multiplex ratio
|
||||
U8X8_CA(0x0b1, 0x0f1), //set phase leghth
|
||||
U8X8_CA(0x0b3, 0x000), //set dclk, 80Hz:0xc1 90Hz:0xe1 100Hz:0x00 110Hz:0x30 120Hz:0x50 130Hz:0x70 01
|
||||
U8X8_CA(0x0ab, 0x001), //
|
||||
U8X8_CA(0x0b6, 0x00f), //set phase leghth
|
||||
U8X8_CA(0x0be, 0x00f),
|
||||
U8X8_CA(0x0bc, 0x008),
|
||||
U8X8_CA(0x0d5, 0x062),
|
||||
U8X8_CA(0x0fd, 0x012),
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_ssd1327_ws_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call the 96x96 procedure at the moment */
|
||||
if ( u8x8_d_ssd1327_96x96_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1327_ea_w128128_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_ws_128x128_init_seq);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE )
|
||||
{
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_ea_w128128_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_ea_w128128_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*=============================================*/
|
||||
/*
|
||||
Visonox VGM128096A4W10 128x96 COB
|
||||
https://github.com/olikraus/u8g2/files/4052919/M02289_VGM128096A4W10_Y02.pdf
|
||||
https://github.com/olikraus/u8g2/issues/1090
|
||||
*/
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1327_128x96_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100, /**/
|
||||
/* sda_setup_time_ns = */ 100, /* */
|
||||
/* sck_pulse_width_ns = */ 100, /* */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 1, /* use 1 instead of 4, because the SSD1327 seems to be very slow, Update 9 Aug 2019: The OLED from aliexpress supports 400kHz */
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 60,
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 12,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 96
|
||||
};
|
||||
|
||||
/* https://github.com/SeeedDocument/Grove_OLED_1.12/raw/master/resources/LY120-096096.pdf */
|
||||
/* http://www.seeedstudio.com/wiki/index.php?title=Twig_-_OLED_96x96 */
|
||||
/* values from u8glib */
|
||||
/*
|
||||
Re-map setting in Graphic Display Data RAM, command 0x0a0
|
||||
Bit 0: Column Address Re-map
|
||||
Bit 1: Nibble Re-map
|
||||
Bit 2: Horizontal/Vertical Address Increment
|
||||
Bit 3: Not used, must be 0
|
||||
|
||||
Bit 4: COM Re-map
|
||||
Bit 5: Not used, must be 0
|
||||
Bit 6: COM Split Odd Even
|
||||
Bit 7: Not used, must be 0
|
||||
*/
|
||||
|
||||
/* init values from the Visionox datasheeet section 10.4 */
|
||||
|
||||
static const uint8_t u8x8_d_ssd1327_128x96_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_CA(0x0fd, 0x012), /* unlock display, usually not required because the display is unlocked after reset */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
//U8X8_CA(0x0a8, 0x03f), /* multiplex ratio: 0x03f * 1/64 duty */
|
||||
U8X8_CA(0x0a8, 0x05f), /* multiplex ratio: 0x05f * 1/64 duty */
|
||||
//U8X8_CA(0x0a8, 0x07f), /* multiplex ratio: 0x05f * 1/128duty */
|
||||
U8X8_CA(0x0a1, 0x000), /* display start line */
|
||||
//U8X8_CA(0x0a2, 0x04c), /* display offset, shift mapping ram counter */
|
||||
|
||||
U8X8_CA(0x0a2, 0x020), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a0, 0x051), /* remap configuration */
|
||||
|
||||
|
||||
U8X8_CA(0x0ab, 0x001), /* Enable internal VDD regulator (RESET) */
|
||||
//U8X8_CA(0x081, 0x070), /* contrast, brightness, 0..128 */
|
||||
U8X8_CA(0x081, 0x0df), /* contrast, brightness, 0..128 (0xdf as per datasheet) */
|
||||
U8X8_CA(0x0b1, 0x022), /* phase length */
|
||||
U8X8_CA(0x0b3, 0x050), /* set display clock divide ratio/oscillator frequency */
|
||||
|
||||
//? U8X8_CA(0x0ad, 0x002), /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
//? U8X8_C(0x086), /* full current range (0x084, 0x085, 0x086) */
|
||||
|
||||
U8X8_C(0x0b9), /* use linear lookup table */
|
||||
|
||||
U8X8_CA(0x0bc, 0x010), /* pre-charge voltage level */
|
||||
U8X8_CA(0x0be, 0x005), /* VCOMH voltage */
|
||||
U8X8_CA(0x0b6, 0x00a), /* second precharge */
|
||||
U8X8_CA(0x0d5, 0x062), /* enable second precharge, internal vsl (bit0 = 0) */
|
||||
|
||||
|
||||
|
||||
U8X8_C(0x0a4), /* normal display mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1327_128x96_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a2, 0x020), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a0, 0x051), /* remap configuration */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1327_128x96_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a2, 0x060), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a0, 0x042), /* remap configuration */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_ssd1327_visionox_128x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call the 96x96 procedure at the moment */
|
||||
if ( u8x8_d_ssd1327_96x96_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1327_128x96_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_128x96_init_seq);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE )
|
||||
{
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_128x96_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1327_128x96_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
513
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1329.c
Normal file
513
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1329.c
Normal file
@@ -0,0 +1,513 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1329.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1329_128x96_noname_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0b3, 0x091), /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
|
||||
U8X8_CA(0x0a8, 0x05f), /* multiplex ratio: 0x03f * 1/64 duty - changed by CREESOO, acc. to datasheet, 100317*/
|
||||
U8X8_CA(0x0a2, 0x000), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a1, 0x000), /* display start line */
|
||||
U8X8_CA(0x0ad, 0x002), /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
U8X8_CA(0x0a0, 0x052), /* remap configuration, horizontal address increment (bit 2 = 0), enable nibble remap (upper nibble is left, bit 1 = 1) */
|
||||
U8X8_C(0x086), /* full current range (0x084, 0x085, 0x086) */
|
||||
#ifdef removed
|
||||
U8X8_C(0x0b8), /* set gray scale table */
|
||||
U8X8_A(1), /* */
|
||||
U8X8_A(5), /* */
|
||||
U8X8_A(10), /* */
|
||||
U8X8_A(14), /* */
|
||||
U8X8_A(19), /* */
|
||||
U8X8_A(23), /* */
|
||||
U8X8_A(28), /* */
|
||||
U8X8_A(32), /* */
|
||||
U8X8_A(37), /* */
|
||||
U8X8_A(41), /* */
|
||||
U8X8_A(46), /* */
|
||||
U8X8_A(50), /* */
|
||||
U8X8_A(55), /* */
|
||||
U8X8_A(59), /* */
|
||||
U8X8_A(63), /* */
|
||||
#endif
|
||||
|
||||
U8X8_C(0x0b7), /* set default gray scale table */
|
||||
|
||||
U8X8_CA(0x081, 0x070), /* contrast, brightness, 0..128 */
|
||||
U8X8_CA(0x0b2, 0x051), /* frame frequency (row period) */
|
||||
U8X8_CA(0x0b1, 0x055), /* phase length */
|
||||
U8X8_CA(0x0bc, 0x010), /* pre-charge voltage level */
|
||||
U8X8_CA(0x0b4, 0x002), /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
U8X8_CA(0x0b0, 0x028), /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
U8X8_CA(0x0be, 0x01c), /* VCOMH voltage */
|
||||
U8X8_CA(0x0bf, 0x002|0x00d), /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
U8X8_C(0x0a4), /* normal display mode */
|
||||
|
||||
U8X8_CA(0x023, 0x003), /* graphics accelleration: fill pixel */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1329_128x96_nhd_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1329_128x96_nhd_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1329_128x96_nhd_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a0, 0x052), /* remap */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1329_128x96_nhd_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a0, 0x041), /* remap */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
input:
|
||||
one tile (8 Bytes)
|
||||
output:
|
||||
Tile for ssd1329 (32 Bytes)
|
||||
*/
|
||||
|
||||
static uint8_t u8x8_ssd1329_8to32_dest_buf[32];
|
||||
|
||||
static uint8_t *u8x8_ssd1329_8to32(U8X8_UNUSED u8x8_t *u8x8, uint8_t *ptr)
|
||||
{
|
||||
uint8_t v;
|
||||
uint8_t a,b;
|
||||
uint8_t i, j;
|
||||
uint8_t *dest;
|
||||
|
||||
for( j = 0; j < 4; j++ )
|
||||
{
|
||||
dest = u8x8_ssd1329_8to32_dest_buf;
|
||||
dest += j;
|
||||
a =*ptr;
|
||||
ptr++;
|
||||
b = *ptr;
|
||||
ptr++;
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
v = 0;
|
||||
if ( a&1 ) v |= 0xf0;
|
||||
if ( b&1 ) v |= 0x0f;
|
||||
*dest = v;
|
||||
dest+=4;
|
||||
a >>= 1;
|
||||
b >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return u8x8_ssd1329_8to32_dest_buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1329_128x96_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1329_128x96_nhd_display_info);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1329_128x96_noname_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1329_128x96_nhd_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1329_128x96_nhd_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1329_128x96_nhd_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1329_128x96_nhd_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1329 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 4;
|
||||
|
||||
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
|
||||
y *= 8;
|
||||
y += u8x8->x_offset; /* x_offset is used as y offset for the ssd1329 */
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
|
||||
do
|
||||
{
|
||||
if ( ptr[0] | ptr[1] | ptr[2] | ptr[3] | ptr[4] | ptr[5] | ptr[6] | ptr[7] )
|
||||
{
|
||||
/* draw the tile if pattern is not zero for all bytes */
|
||||
u8x8_cad_SendCmd(u8x8, 0x015 ); /* set column address */
|
||||
u8x8_cad_SendArg(u8x8, x ); /* start */
|
||||
u8x8_cad_SendArg(u8x8, x+3 ); /* end */
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x075 ); /* set row address */
|
||||
u8x8_cad_SendArg(u8x8, y);
|
||||
u8x8_cad_SendArg(u8x8, y+7);
|
||||
|
||||
|
||||
u8x8_cad_SendData(u8x8, 32, u8x8_ssd1329_8to32(u8x8, ptr));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* tile is empty, use the graphics acceleration command */
|
||||
/* are this really available on the SSD1329??? */
|
||||
u8x8_cad_SendCmd(u8x8, 0x024 ); // draw rectangle
|
||||
u8x8_cad_SendArg(u8x8, x );
|
||||
u8x8_cad_SendArg(u8x8, y );
|
||||
u8x8_cad_SendArg(u8x8, x+3 );
|
||||
u8x8_cad_SendArg(u8x8, y+7 );
|
||||
u8x8_cad_SendArg(u8x8, 0 ); // clear
|
||||
}
|
||||
ptr += 8;
|
||||
x += 4;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
|
||||
//x += 4;
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1329_128x96_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 15,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100, /**/
|
||||
/* sda_setup_time_ns = */ 100, /* ssd1329 */
|
||||
/* sck_pulse_width_ns = */ 100, /* ssd1329 */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 60, /* ssd1329 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 12,
|
||||
/* default_x_offset = */ 0, /* x_offset is used as y offset for the ssd1329 */
|
||||
/* flipmode_x_offset = */ 0, /* x_offset is used as y offset for the ssd1329 */
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 96
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1329_128x96_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1329_128x96_display_info);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1329_128x96_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
/*=================================================*/
|
||||
/*
|
||||
SSD1329 with 96x96
|
||||
For this display, the x_offset has been reverted to its original meaning!
|
||||
|
||||
https://github.com/olikraus/u8g2/issues/1511
|
||||
|
||||
FlipMode 1 probably does not work, see issue
|
||||
*/
|
||||
|
||||
static const uint8_t u8x8_d_ssd1329_96x96_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a2, 0x000), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a1, 0x000), /* display start line */
|
||||
U8X8_CA(0x0a0, 0x042), /* remap */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1329_96x96_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0a2, 0x060), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a1, 0x000), /* display start line */
|
||||
U8X8_CA(0x0a0, 0x051), /* remap */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1329_96x96_noname_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_CA(0x0b3, 0x0f0), /* set display clock divide ratio/oscillator frequency, see #1511*/
|
||||
U8X8_CA(0x0a8, 0x05f), /* multiplex ratio: 0x03f * 1/64 duty */
|
||||
U8X8_CA(0x0a2, 0x000), /* display offset, shift mapping ram counter */
|
||||
U8X8_CA(0x0a1, 0x000), /* display start line */
|
||||
U8X8_CA(0x0ad, 0x002), /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
U8X8_CA(0x0a0, 0x042), /* remap configuration, horizontal address increment (bit 2 = 0), enable nibble remap (upper nibble is left, bit 1 = 1) */
|
||||
U8X8_C(0x086), /* full current range (0x084, 0x085, 0x086) */
|
||||
#ifdef removed
|
||||
U8X8_C(0x0b8), /* set gray scale table */
|
||||
U8X8_A(1), /* */
|
||||
U8X8_A(5), /* */
|
||||
U8X8_A(10), /* */
|
||||
U8X8_A(14), /* */
|
||||
U8X8_A(19), /* */
|
||||
U8X8_A(23), /* */
|
||||
U8X8_A(28), /* */
|
||||
U8X8_A(32), /* */
|
||||
U8X8_A(37), /* */
|
||||
U8X8_A(41), /* */
|
||||
U8X8_A(46), /* */
|
||||
U8X8_A(50), /* */
|
||||
U8X8_A(55), /* */
|
||||
U8X8_A(59), /* */
|
||||
U8X8_A(63), /* */
|
||||
#endif
|
||||
|
||||
U8X8_C(0x0b7), /* set default gray scale table */
|
||||
|
||||
U8X8_CA(0x081, 0x070), /* contrast, brightness, 0..255 */
|
||||
U8X8_CA(0x0b2, 0x023), /* frame frequency (row period), see #1511 */
|
||||
U8X8_CA(0x0b1, 0x021), /* phase length, see #1511 */
|
||||
U8X8_CA(0x0bc, 0x010), /* pre-charge voltage level */
|
||||
U8X8_CA(0x0b4, 0x002), /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
U8X8_CA(0x0b0, 0x028), /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
U8X8_CA(0x0be, 0x01f), /* VCOMH voltage */
|
||||
U8X8_CA(0x0bf, 0x002|0x00d), /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
U8X8_C(0x0a4), /* normal display mode */
|
||||
|
||||
U8X8_CA(0x023, 0x003), /* graphics accelleration: fill pixel */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1329_96x96_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1329_128x96_nhd_display_info);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1329_96x96_noname_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1329_128x96_nhd_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1329_128x96_nhd_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1329_96x96_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1329_96x96_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1329 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 4;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
|
||||
y *= 8;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
|
||||
do
|
||||
{
|
||||
if ( ptr[0] | ptr[1] | ptr[2] | ptr[3] | ptr[4] | ptr[5] | ptr[6] | ptr[7] )
|
||||
{
|
||||
/* draw the tile if pattern is not zero for all bytes */
|
||||
u8x8_cad_SendCmd(u8x8, 0x015 ); /* set column address */
|
||||
u8x8_cad_SendArg(u8x8, x ); /* start */
|
||||
u8x8_cad_SendArg(u8x8, x+3 ); /* end */
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x075 ); /* set row address */
|
||||
u8x8_cad_SendArg(u8x8, y);
|
||||
u8x8_cad_SendArg(u8x8, y+7);
|
||||
|
||||
|
||||
u8x8_cad_SendData(u8x8, 32, u8x8_ssd1329_8to32(u8x8, ptr));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* tile is empty, use the graphics acceleration command */
|
||||
/* are this really available on the SSD1329??? */
|
||||
u8x8_cad_SendCmd(u8x8, 0x024 ); // draw rectangle
|
||||
u8x8_cad_SendArg(u8x8, x );
|
||||
u8x8_cad_SendArg(u8x8, y );
|
||||
u8x8_cad_SendArg(u8x8, x+3 );
|
||||
u8x8_cad_SendArg(u8x8, y+7 );
|
||||
u8x8_cad_SendArg(u8x8, 0 ); // clear
|
||||
}
|
||||
ptr += 8;
|
||||
x += 4;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
|
||||
//x += 4;
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1329_96x96_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 15,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100, /**/
|
||||
/* sda_setup_time_ns = */ 100, /* ssd1329 */
|
||||
/* sck_pulse_width_ns = */ 100, /* ssd1329 */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 60, /* ssd1329 */
|
||||
/* tile_width = */ 12,
|
||||
/* tile_hight = */ 12,
|
||||
/* default_x_offset = */ 0, /* x offset for flip mode 0 */
|
||||
/* flipmode_x_offset = */ 16, /* x offset for flip mode 1 */
|
||||
/* pixel_width = */ 96,
|
||||
/* pixel_height = */ 96
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1329_96x96_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1329_96x96_display_info);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1329_96x96_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
394
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1606_172x72.c
Normal file
394
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1606_172x72.c
Normal file
@@ -0,0 +1,394 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1606_172x72.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SSD1606: 128x180x2
|
||||
two-bit, four graylevels
|
||||
command
|
||||
0x22: assign actions
|
||||
0x20: execute actions
|
||||
|
||||
action for command 0x022 are (more or less guessed)
|
||||
bit 7: Enable Clock
|
||||
bit 6: Enable Charge Pump
|
||||
bit 5: Load Temparture Value (???)
|
||||
bit 4: Load LUT (???)
|
||||
bit 3: Initial Display (???)
|
||||
bit 2: Pattern Display --> Requires about 945ms with the LUT from below
|
||||
bit 1: Disable Charge Pump
|
||||
bit 0: Disable Clock
|
||||
|
||||
Disable Charge Pump and Clock require about 267ms
|
||||
Enable Charge Pump and Clock require about 10ms
|
||||
|
||||
Notes:
|
||||
- Introduced a refresh display message, which copies RAM to display
|
||||
- Charge pump and clock are only enabled for the transfer RAM to display
|
||||
- U8x8 will not really work because of the two buffers in the SSD1606, however U8g2 should be ok.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
#define L(a,b,c,d) (((a)<<6)|((b)<<4)|((c)<<2)|(d))
|
||||
|
||||
|
||||
/* GDE021A1, 2.1" EPD */
|
||||
static const uint8_t u8x8_d_ssd1606_172x72_gde021a1_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_CA(0x10, 0x00), /* Deep Sleep mode Control: Disable */
|
||||
U8X8_CA(0x11, 0x03), /* Define data entry mode, x&y inc, x first */
|
||||
U8X8_CAA(0x44, 0, 31), /* RAM x start & end, each byte has 4 pixel, 32*4=128 */
|
||||
U8X8_CAA(0x45, 0, 179), /* RAM y start & end, 179 MAX */
|
||||
|
||||
U8X8_CA(0x4e, 0), /* set x pos, 0..31 */
|
||||
U8X8_CA(0x4f, 0), /* set y pos, 0...179 */
|
||||
|
||||
U8X8_CA(0xf0, 0x1f), /* set booster feedback to internal */
|
||||
U8X8_CA(0x22, 0xc0), /* display update seq. option: enable clk, enable CP, .... todo: this is never activated */
|
||||
|
||||
U8X8_C(0x32), /* write LUT register*/
|
||||
|
||||
#ifdef ORIGINAL_LUT
|
||||
|
||||
/* wavefrom part of the LUT: absolute LUT... this will always force the destination color */
|
||||
U8X8_A4(0x00,0x00,0x00,0x55), /* step 0 */
|
||||
U8X8_A4(0x00,0x00,0x55,0x55), /* step 1 */
|
||||
U8X8_A4(0x00,0x55,0x55,0x55),
|
||||
U8X8_A4(0xAA,0xAA,0xAA,0xAA),
|
||||
U8X8_A4(0x15,0x15,0x15,0x15),
|
||||
U8X8_A4(0x05,0x05,0x05,0x05),
|
||||
U8X8_A4(0x01,0x01,0x01,0x01),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00), /* step 19 */
|
||||
|
||||
/* timing part of the LUT */
|
||||
U8X8_A8(0x22,0xFB,0x22,0x1B,0x00,0x00,0x00,0x00),
|
||||
U8X8_A(0x00),U8X8_A(0x00),
|
||||
|
||||
#else
|
||||
|
||||
/* the following LUT will not change anything if the old and the new values are the same */
|
||||
/* 03 02 01 00 13 12 11 10 23 22 21 20 33 32 31 30 original */
|
||||
U8X8_A4(L(0, 0, 0, 0), L(0, 0, 0, 0), L(0, 0, 0, 0), L(0, 1, 1, 1)), // 0x00,0x00,0x00,0x55, step 0
|
||||
U8X8_A4(L(0, 0, 0, 0), L(0, 0, 0, 0), L(1, 0, 1, 1), L(0, 1, 1, 1)), // 0x00,0x00,0x55,0x55, step 1
|
||||
U8X8_A4(L(0, 0, 0, 0), L(1, 1, 0, 1), L(1, 0, 1, 1), L(0, 1, 1, 1)), // 0x00,0x55,0x55,0x55, step 2
|
||||
U8X8_A4(L(2, 2, 2, 0), L(2, 2, 0, 2), L(2, 0, 2, 2), L(0, 2, 2, 2)), // 0xAA,0xAA,0xAA,0xAA, step 3
|
||||
U8X8_A4(L(0, 1, 1, 0), L(0, 1, 0, 1), L(0, 0, 1, 1), L(0, 1, 1, 1)), // 0x15,0x15,0x15,0x15, step 4
|
||||
U8X8_A4(L(0, 0, 1, 0), L(0, 0, 0, 1), L(0, 0, 1, 1), L(0, 0, 1, 1)), // 0x05,0x05,0x05,0x05, step 5
|
||||
U8X8_A4(L(0, 0, 0, 0), L(0, 0, 0, 1), L(0, 0, 0, 1), L(0, 0, 0, 1)), // 0x01,0x01,0x01,0x01, step 6
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00),
|
||||
U8X8_A4(0x00,0x00,0x00,0x00), /* step 19 */
|
||||
|
||||
/* timing part of the LUT */
|
||||
U8X8_A8(0x22,0xFB,0x22,0x1B,0x00,0x00,0x00,0x00),
|
||||
U8X8_A(0x00),U8X8_A(0x00),
|
||||
|
||||
#endif
|
||||
|
||||
U8X8_CA(0x2c, 0xa0), /* write vcom value*/
|
||||
U8X8_CA(0x3c, 0x63), /* select boarder waveform */
|
||||
U8X8_CA(0x22, 0xc4), /* display update seq. option: clk -> CP -> LUT -> initial display -> pattern display */
|
||||
/* 0x0c4 is mentioned in chapter 9.2 of the GDE021A1 data sheet */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1606_to_display_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
//U8X8_CA(0x22, 0xc0), /* display update seq. option: Enable clock and charge pump */
|
||||
//U8X8_C(0x20), /* execute sequence */
|
||||
//U8X8_DLY(10),
|
||||
/* strange, splitting 0x0c0 does not work reliable */
|
||||
|
||||
U8X8_CA(0x22, 0xc4), /* display update seq. option: clk -> CP -> LUT -> initial display -> pattern display */
|
||||
U8X8_C(0x20), /* execute sequence */
|
||||
U8X8_DLY(250), /* the sequence above requires about 970ms */
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(230),
|
||||
|
||||
U8X8_CA(0x22, 0x03), /* disable clock and charge pump */
|
||||
U8X8_DLY(200), /* this requres about 270ms */
|
||||
U8X8_DLY(90),
|
||||
|
||||
//U8X8_CA(0x10, 0x01), /* deep sleep mode */
|
||||
//U8X8_C(0x20), /* execute sequence */
|
||||
U8X8_DLY(50),
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
// static const uint8_t u8x8_d_ssd1606_172x72_powersave0_seq[] = {
|
||||
// U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
// U8X8_END_TRANSFER(), /* disable chip */
|
||||
// U8X8_END() /* end of sequence */
|
||||
// };
|
||||
|
||||
|
||||
// static const uint8_t u8x8_d_ssd1606_172x72_powersave1_seq[] = {
|
||||
// U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
// U8X8_END_TRANSFER(), /* disable chip */
|
||||
// U8X8_END() /* end of sequence */
|
||||
// };
|
||||
|
||||
// static const uint8_t u8x8_d_ssd1606_172x72_flip0_seq[] = {
|
||||
// U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
// U8X8_END_TRANSFER(), /* disable chip */
|
||||
// U8X8_END() /* end of sequence */
|
||||
// };
|
||||
|
||||
// static const uint8_t u8x8_d_ssd1606_172x72_flip1_seq[] = {
|
||||
// U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
// U8X8_END_TRANSFER(), /* disable chip */
|
||||
// U8X8_END() /* end of sequence */
|
||||
// };
|
||||
|
||||
|
||||
static uint8_t *u8x8_convert_tile_for_ssd1606(uint8_t *t)
|
||||
{
|
||||
uint8_t i;
|
||||
uint16_t r;
|
||||
static uint8_t buf[16];
|
||||
uint8_t *pbuf = buf;
|
||||
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
r = u8x8_upscale_byte(~(*t++));
|
||||
*pbuf++ = (r>>8) & 255;
|
||||
*pbuf++ = r & 255;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void u8x8_d_ssd1606_draw_tile(u8x8_t *u8x8, uint8_t arg_int, void *arg_ptr) U8X8_NOINLINE;
|
||||
static void u8x8_d_ssd1606_draw_tile(u8x8_t *u8x8, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c, page;
|
||||
uint8_t *ptr;
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
page = u8x8->display_info->tile_height;
|
||||
page --;
|
||||
page -= (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
page *= 2;
|
||||
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x00f ); /* scan start */
|
||||
u8x8_cad_SendArg(u8x8, 0);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x011 ); /* cursor increment mode */
|
||||
u8x8_cad_SendArg(u8x8, 3);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x045 ); /* window start column */
|
||||
u8x8_cad_SendArg(u8x8, 0);
|
||||
u8x8_cad_SendArg(u8x8, 179); /* end of display */
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x044 ); /* window end page */
|
||||
u8x8_cad_SendArg(u8x8, page);
|
||||
u8x8_cad_SendArg(u8x8, page+1);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x04f ); /* window column */
|
||||
u8x8_cad_SendArg(u8x8, x);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x04e ); /* window row */
|
||||
u8x8_cad_SendArg(u8x8, page);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x024 );
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 16, u8x8_convert_tile_for_ssd1606(ptr));
|
||||
ptr += 8;
|
||||
x += 8;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
}
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1606_172x72_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1606_172x72_display_info);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1606_172x72_gde021a1_init_seq);
|
||||
|
||||
/* special code for the SSD1606... */
|
||||
/* ensure that the initial buffer is clear and all eInk is set to white */
|
||||
/* this is done here, because the LUT will be of that kind, that it uses the previous color */
|
||||
/* make everything black */
|
||||
u8x8_FillDisplay(u8x8);
|
||||
/* write content to the display */
|
||||
u8x8_RefreshDisplay(u8x8);
|
||||
/* now make everything clear */
|
||||
u8x8_FillDisplay(u8x8);
|
||||
/* write content to the display */
|
||||
u8x8_RefreshDisplay(u8x8);
|
||||
/* now make everything clear */
|
||||
u8x8_ClearDisplay(u8x8);
|
||||
/* write content to the display */
|
||||
u8x8_RefreshDisplay(u8x8);
|
||||
|
||||
u8x8_ClearDisplay(u8x8);
|
||||
/* write content to the display */
|
||||
u8x8_RefreshDisplay(u8x8);
|
||||
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
/*
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1606_172x72_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1606_172x72_powersave1_seq);
|
||||
*/
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
/*
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1606_172x72_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1606_172x72_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
*/
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
/*
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
*/
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_d_ssd1606_draw_tile(u8x8, arg_int, arg_ptr);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_REFRESH:
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1606_to_display_seq);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1606_172x72_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 120,
|
||||
/* pre_chip_disable_wait_ns = */ 60,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100,
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1606: */
|
||||
/* sck_pulse_width_ns = */ 100, /* SSD1606: 100ns */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150,
|
||||
/* tile_width = */ 22, /* 22*8 = 176 */
|
||||
/* tile_hight = */ 9, /* 9*8 = 72 */
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 172,
|
||||
/* pixel_height = */ 72
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1606_172x72(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1606_172x72_display_info);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1606_172x72_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
718
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1607_200x200.c
Normal file
718
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_ssd1607_200x200.c
Normal file
@@ -0,0 +1,718 @@
|
||||
/*
|
||||
|
||||
u8x8_d_ssd1607_200x200.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SSD1607: 200x300x1
|
||||
|
||||
command
|
||||
0x22: assign actions
|
||||
0x20: execute actions
|
||||
|
||||
action for command 0x022 are (more or less guessed)
|
||||
bit 7: Enable Clock
|
||||
bit 6: Enable Charge Pump
|
||||
bit 5: Load Temparture Value (???)
|
||||
bit 4: Load LUT (???)
|
||||
bit 3: Initial Display (???)
|
||||
bit 2: Pattern Display --> Requires about 945ms with the LUT from below
|
||||
bit 1: Disable Charge Pump
|
||||
bit 0: Disable Clock
|
||||
|
||||
Disable Charge Pump and Clock require about 267ms
|
||||
Enable Charge Pump and Clock require about 10ms
|
||||
|
||||
Notes:
|
||||
- Introduced a refresh display message, which copies RAM to display
|
||||
- Charge pump and clock are only enabled for the transfer RAM to display
|
||||
- U8x8 will not really work because of the two buffers in the SSD1606, however U8g2 should be ok.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
/*=================================================*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1607_200x200_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* values from SSD1606 */
|
||||
/* post_chip_enable_wait_ns = */ 120,
|
||||
/* pre_chip_disable_wait_ns = */ 60,
|
||||
/* reset_pulse_width_ms = */ 100,
|
||||
/* post_reset_wait_ms = */ 100,
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1606: */
|
||||
/* sck_pulse_width_ns = */ 100, /* SSD1606: 100ns */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150,
|
||||
/* tile_width = */ 25, /* 25*8 = 200 */
|
||||
/* tile_hight = */ 25,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 200,
|
||||
/* pixel_height = */ 200
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1607_200x200_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x22, 0xc0), /* enable clock and charge pump */
|
||||
U8X8_C(0x20), /* execute sequence */
|
||||
U8X8_DLY(200), /* according to my measures it may take up to 150ms */
|
||||
U8X8_DLY(100), /* but it might take longer */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1607_200x200_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
/* disable clock and charge pump only, deep sleep is not entered, because we will loose RAM content */
|
||||
U8X8_CA(0x22, 0x02), /* only disable charge pump, HW reset seems to be required if the clock is disabled */
|
||||
U8X8_C(0x20), /* execute sequence */
|
||||
U8X8_DLY(20),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1607_200x200_exec_1000dly_seq[] = {
|
||||
// assumes, that the start transfer has happend
|
||||
U8X8_CA(0x22, 0x04), /* display update seq. option: pattern display */
|
||||
U8X8_C(0x20), /* execute sequence */
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static void u8x8_d_ssd1607_200x200_first_init(u8x8_t *u8x8)
|
||||
{
|
||||
u8x8_ClearDisplay(u8x8);
|
||||
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x032); // program update sequence
|
||||
u8x8_cad_SendMultipleArg(u8x8, 8, 0x055); // all black
|
||||
u8x8_cad_SendMultipleArg(u8x8, 12, 0x0aa); // all white
|
||||
u8x8_cad_SendMultipleArg(u8x8, 10, 0x022); // 830ms
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_200x200_exec_1000dly_seq);
|
||||
|
||||
}
|
||||
|
||||
static uint8_t *u8x8_convert_tile_for_ssd1607(uint8_t *t)
|
||||
{
|
||||
uint8_t i;
|
||||
static uint8_t buf[8];
|
||||
uint8_t *pbuf = buf;
|
||||
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
*pbuf++ = ~(*t++);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void u8x8_d_ssd1607_draw_tile(u8x8_t *u8x8, uint8_t arg_int, void *arg_ptr) U8X8_NOINLINE;
|
||||
static void u8x8_d_ssd1607_draw_tile(u8x8_t *u8x8, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint16_t x;
|
||||
uint8_t c, page;
|
||||
uint8_t *ptr;
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
page = u8x8->display_info->tile_height;
|
||||
page --;
|
||||
page -= (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x045 ); /* window start column */
|
||||
u8x8_cad_SendArg(u8x8, x&255);
|
||||
u8x8_cad_SendArg(u8x8, x>>8);
|
||||
u8x8_cad_SendArg(u8x8, 199); /* end of display */
|
||||
u8x8_cad_SendArg(u8x8, 0);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x044 ); /* window end page */
|
||||
u8x8_cad_SendArg(u8x8, page);
|
||||
u8x8_cad_SendArg(u8x8, page);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x04f ); /* window column */
|
||||
u8x8_cad_SendArg(u8x8, x&255);
|
||||
u8x8_cad_SendArg(u8x8, x>>8);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x04e ); /* window row */
|
||||
u8x8_cad_SendArg(u8x8, page);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x024 );
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 8, u8x8_convert_tile_for_ssd1607(ptr));
|
||||
ptr += 8;
|
||||
x += 8;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*=================================================*/
|
||||
|
||||
|
||||
#define L(a,b,c,d) (((a)<<6)|((b)<<4)|((c)<<2)|(d))
|
||||
|
||||
|
||||
/* https://github.com/embeddedadventures/SSD1607/blob/master/SSD1607.cpp */
|
||||
static const uint8_t u8x8_d_ssd1607_200x200_init_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
//U8X8_CA(0x10, 0x00), /* Deep Sleep mode Control: Disable */
|
||||
U8X8_C(0x01),
|
||||
U8X8_A(199),U8X8_A(0),U8X8_A(0),
|
||||
|
||||
|
||||
U8X8_CA(0x03, 0x00), /* Gate Driving voltage: 15V (lowest value)*/
|
||||
U8X8_CA(0x04, 0x0a), /* Source Driving voltage: 15V (mid value and POR)*/
|
||||
|
||||
U8X8_CA(0x0f, 0x00), /* scan start ? */
|
||||
|
||||
U8X8_CA(0xf0, 0x1f), /* set booster feedback to internal */
|
||||
|
||||
U8X8_CA(0x2c, 0xa8), /* write vcom value*/
|
||||
U8X8_CA(0x3a, 0x1a), /* dummy lines */
|
||||
U8X8_CA(0x3b, 0x08), /* gate time */
|
||||
U8X8_CA(0x3c, 0x33), /* select boarder waveform */
|
||||
|
||||
U8X8_CA(0x11, 0x03), /* cursor increment mode */
|
||||
U8X8_CAA(0x44, 0, 24), /* RAM x start & end, each byte has 8 pixel, 25*4=200 */
|
||||
U8X8_CAAAA(0x45, 0, 0, 299&255, 299>>8), /* RAM y start & end, 0..299 */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_ssd1607_to_display_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x32), /* write LUT register*/
|
||||
|
||||
|
||||
/* according to the command table, the lut has 240 bits (=30 bytes * 8 bits) */
|
||||
|
||||
/* Waveform part of the LUT (20 bytes) */
|
||||
/* bit 7/6: 1 - 1 transition */
|
||||
/* bit 5/4: 1 - 0 transition */
|
||||
/* bit 3/2: 0 - 1 transition */
|
||||
/* bit 1/0: 0 - 0 transition */
|
||||
/* 00 – VSS */
|
||||
/* 01 – VSH */
|
||||
/* 10 – VSL */
|
||||
/* 11 – NA */
|
||||
|
||||
/* original values */
|
||||
/*
|
||||
U8X8_A(0x02),
|
||||
U8X8_A(0x02),
|
||||
U8X8_A(0x01),
|
||||
U8X8_A(0x11),
|
||||
U8X8_A(0x12),
|
||||
U8X8_A(0x12),
|
||||
U8X8_A(0x22),
|
||||
U8X8_A(0x22),
|
||||
U8X8_A(0x66),
|
||||
U8X8_A(0x69),
|
||||
U8X8_A(0x69),
|
||||
U8X8_A(0x59),
|
||||
U8X8_A(0x58),
|
||||
U8X8_A(0x99),
|
||||
U8X8_A(0x99),
|
||||
U8X8_A(0x88),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
*/
|
||||
|
||||
/* original values, L-macro */
|
||||
U8X8_A(L(0,0,0,2)), // 0x02
|
||||
U8X8_A(L(0,0,0,2)), // 0x02
|
||||
U8X8_A(L(0,0,0,1)), // 0x01
|
||||
U8X8_A(L(0,1,0,1)), // 0x11
|
||||
U8X8_A(L(0,1,0,2)), // 0x12
|
||||
U8X8_A(L(0,1,0,2)), // 0x12
|
||||
U8X8_A(L(0,2,0,2)), // 0x22
|
||||
U8X8_A(L(0,2,0,2)), // 0x22
|
||||
U8X8_A(L(1,2,1,2)), // 0x66
|
||||
U8X8_A(L(1,2,2,1)), // 0x69
|
||||
U8X8_A(L(1,2,2,1)), // 0x69
|
||||
U8X8_A(L(1,1,2,1)), // 0x59
|
||||
U8X8_A(L(1,1,2,0)), // 0x58
|
||||
U8X8_A(L(2,1,2,1)), // 0x99
|
||||
U8X8_A(L(2,1,2,1)), // 0x99
|
||||
U8X8_A(L(2,0,2,0)), // 0x88
|
||||
U8X8_A(L(0,0,0,0)), // 0x00
|
||||
U8X8_A(L(0,0,0,0)), // 0x00
|
||||
U8X8_A(L(0,0,0,0)), // 0x00
|
||||
U8X8_A(L(0,0,0,0)), // 0x00
|
||||
|
||||
|
||||
/* orginal values without 0-0 and 1-1 transition */
|
||||
/*
|
||||
U8X8_A(L(3,0,0,3)), // 0x02
|
||||
U8X8_A(L(3,0,0,3)), // 0x02
|
||||
U8X8_A(L(3,0,0,3)), // 0x01
|
||||
U8X8_A(L(3,1,0,3)), // 0x11
|
||||
U8X8_A(L(3,1,0,3)), // 0x12
|
||||
U8X8_A(L(3,1,0,3)), // 0x12
|
||||
U8X8_A(L(3,2,0,3)), // 0x22
|
||||
U8X8_A(L(3,2,0,3)), // 0x22
|
||||
U8X8_A(L(3,2,1,3)), // 0x66
|
||||
U8X8_A(L(3,2,2,3)), // 0x69
|
||||
U8X8_A(L(3,2,2,3)), // 0x69
|
||||
U8X8_A(L(3,1,2,3)), // 0x59
|
||||
U8X8_A(L(3,1,2,3)), // 0x58
|
||||
U8X8_A(L(3,1,2,3)), // 0x99
|
||||
U8X8_A(L(3,1,2,3)), // 0x99
|
||||
U8X8_A(L(3,0,2,3)), // 0x88
|
||||
U8X8_A(L(3,0,0,3)), // 0x00
|
||||
U8X8_A(L(3,0,0,3)), // 0x00
|
||||
U8X8_A(L(3,0,0,3)), // 0x00
|
||||
U8X8_A(L(3,0,0,3)), // 0x00
|
||||
*/
|
||||
|
||||
|
||||
/* Timing part of the LUT, 20 Phases with 4 bit each: 10 bytes */
|
||||
U8X8_A(0xF8),
|
||||
U8X8_A(0xB4),
|
||||
U8X8_A(0x13),
|
||||
U8X8_A(0x51),
|
||||
U8X8_A(0x35),
|
||||
U8X8_A(0x51),
|
||||
U8X8_A(0x51),
|
||||
U8X8_A(0x19),
|
||||
U8X8_A(0x01),
|
||||
U8X8_A(0x00),
|
||||
|
||||
|
||||
U8X8_CA(0x22, 0x04), /* display update seq. option: clk -> CP -> LUT -> initial display -> pattern display */
|
||||
U8X8_C(0x20), /* execute sequence */
|
||||
U8X8_DLY(250), /* the sequence above requires about 1200ms for the 200x200 display*/
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_ssd1607_200x200(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1607_200x200_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_200x200_init_seq);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_200x200_powersave0_seq);
|
||||
u8x8_d_ssd1607_200x200_first_init(u8x8);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_200x200_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_200x200_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_d_ssd1607_draw_tile(u8x8, arg_int, arg_ptr);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_REFRESH:
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_to_display_seq);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*=================================================*/
|
||||
/* there is no improvement possible... so i consider the v2 version as obsolete */
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1607_v2_to_display_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
/*
|
||||
0xaa, 0x09, 0x09, 0x19, 0x19,
|
||||
0x11, 0x11, 0x11, 0x11, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x75, 0x77, 0x77, 0x77, 0x07,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00
|
||||
measured 1240 ms with IL3830 196x128
|
||||
|
||||
|
||||
0x02, 0x02, 0x01, 0x11, 0x12,
|
||||
0x12, 0x12, 0x22, 0x22, 0x66,
|
||||
0x69, 0x59, 0x58, 0x99, 0x99,
|
||||
0x88, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0xf8, 0xb4, 0x13, 0x51, 0x35,
|
||||
0x51, 0x51, 0xe9, 0x04, 0x00
|
||||
|
||||
*/
|
||||
|
||||
U8X8_C(0x32), /* write LUT register*/
|
||||
|
||||
/* https://github.com/olikraus/u8g2/issues/347 */
|
||||
U8X8_A(0x02),
|
||||
U8X8_A(0x02),
|
||||
U8X8_A(0x01),
|
||||
U8X8_A(0x11),
|
||||
U8X8_A(0x12),
|
||||
U8X8_A(0x12),
|
||||
U8X8_A(0x22),
|
||||
U8X8_A(0x22),
|
||||
U8X8_A(0x66),
|
||||
U8X8_A(0x69),
|
||||
U8X8_A(0x69),
|
||||
U8X8_A(0x59),
|
||||
U8X8_A(0x58),
|
||||
U8X8_A(0x99),
|
||||
U8X8_A(0x99),
|
||||
|
||||
U8X8_A(0x88),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
U8X8_A(0x00),
|
||||
|
||||
/* Timing part of the LUT, 20 Phases with 4 bit each: 10 bytes */
|
||||
U8X8_A(0xF8),
|
||||
U8X8_A(0xB4),
|
||||
U8X8_A(0x13),
|
||||
U8X8_A(0x51),
|
||||
U8X8_A(0x35),
|
||||
|
||||
U8X8_A(0x51),
|
||||
U8X8_A(0x51),
|
||||
U8X8_A(0xe9),
|
||||
U8X8_A(0x04),
|
||||
U8X8_A(0x00),
|
||||
|
||||
U8X8_CA(0x22, 0x04), /* display update seq. option: clk -> CP -> LUT -> initial display -> pattern display */
|
||||
U8X8_C(0x20), /* execute sequence */
|
||||
|
||||
U8X8_DLY(250), /* delay for 1500ms. The current sequence takes 1300ms */
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_ssd1607_v2_200x200(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1607_200x200_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_200x200_init_seq);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_200x200_powersave0_seq);
|
||||
u8x8_d_ssd1607_200x200_first_init(u8x8);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_200x200_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_200x200_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_d_ssd1607_draw_tile(u8x8, arg_int, arg_ptr);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_REFRESH:
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_v2_to_display_seq);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*=================================================*/
|
||||
/* GDEP015OC1 */
|
||||
/* https://github.com/olikraus/u8g2/issues/454 */
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1607_gd_to_display_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
/*
|
||||
0xaa, 0x09, 0x09, 0x19, 0x19,
|
||||
0x11, 0x11, 0x11, 0x11, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x75, 0x77, 0x77, 0x77, 0x07,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00
|
||||
measured 1240 ms with IL3830 196x128
|
||||
|
||||
|
||||
0x02, 0x02, 0x01, 0x11, 0x12,
|
||||
0x12, 0x12, 0x22, 0x22, 0x66,
|
||||
0x69, 0x59, 0x58, 0x99, 0x99,
|
||||
0x88, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0xf8, 0xb4, 0x13, 0x51, 0x35,
|
||||
0x51, 0x51, 0xe9, 0x04, 0x00
|
||||
|
||||
*/
|
||||
|
||||
U8X8_C(0x32), /* write LUT register*/
|
||||
|
||||
/*
|
||||
U8X8_A(0x50), U8X8_A(0xAA), U8X8_A(0x55), U8X8_A(0xAA), U8X8_A(0x11),
|
||||
U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00),
|
||||
U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00),
|
||||
U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00),
|
||||
|
||||
U8X8_A(0xFF), U8X8_A(0xFF), U8X8_A(0x1F), U8X8_A(0x00), U8X8_A(0x00),
|
||||
U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00),
|
||||
*/
|
||||
U8X8_A(0x10), U8X8_A(0x18), U8X8_A(0x18), U8X8_A(0x08), U8X8_A(0x18), // numbers based on Waveshare demo code
|
||||
U8X8_A(0x18), U8X8_A(0x08), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00),
|
||||
U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00),
|
||||
U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00),
|
||||
|
||||
U8X8_A(0x13), U8X8_A(0x14), U8X8_A(0x44), U8X8_A(0x12), U8X8_A(0x00),
|
||||
U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00),
|
||||
|
||||
U8X8_CA(0x22, 0xc4), /* display update seq. option: clk -> CP -> LUT -> initial display -> pattern display */
|
||||
U8X8_C(0x20), /* execute sequence */
|
||||
|
||||
U8X8_DLY(250), /* delay for 1500ms. The current sequence takes 1300ms */
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
// U8X8_DLY(250),
|
||||
|
||||
// U8X8_DLY(250),
|
||||
// U8X8_DLY(250),
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1607_gd_200x200(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1607_200x200_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_200x200_init_seq);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_200x200_powersave0_seq);
|
||||
u8x8_d_ssd1607_200x200_first_init(u8x8);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_200x200_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_200x200_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_d_ssd1607_draw_tile(u8x8, arg_int, arg_ptr);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_REFRESH:
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_gd_to_display_seq);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*=================================================*/
|
||||
|
||||
static const uint8_t u8x8_d_ssd1607_ws_to_display_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0x32), /* write LUT register*/
|
||||
|
||||
U8X8_A(0x10), U8X8_A(0x18), U8X8_A(0x18), U8X8_A(0x08), U8X8_A(0x18), // numbers based on Waveshare demo code
|
||||
U8X8_A(0x18), U8X8_A(0x08), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00),
|
||||
U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00),
|
||||
U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00),
|
||||
|
||||
U8X8_A(0x13), U8X8_A(0x14), U8X8_A(0x44), U8X8_A(0x12), U8X8_A(0x00),
|
||||
U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00), U8X8_A(0x00),
|
||||
|
||||
U8X8_CA(0x22, 0xc4), /* display update seq. option: clk -> CP -> LUT -> initial display -> pattern display */
|
||||
U8X8_C(0x20), /* execute sequence */
|
||||
|
||||
U8X8_DLY(250), /* delay for 1250ms. */
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
U8X8_DLY(250),
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_ssd1607_ws_to_refresh_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_CA(0x22, 0x04), /* display update seq. option: clk -> CP -> LUT -> initial display -> pattern display */
|
||||
U8X8_C(0x20), /* execute sequence */
|
||||
|
||||
// U8X8_DLY(250),
|
||||
// U8X8_DLY(250),
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/* waveshare 200x200 */
|
||||
static const uint8_t u8x8_d_ssd1607_ws_200x200_init_seq[] = {
|
||||
// suggested code from https://github.com/olikraus/u8g2/issues/637
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x01), /* DRIVER_OUTPUT_CONTROL: LO(EPD_HEIGHT-1), HI(EPD_HEIGHT-1). GD = 0; SM = 0; TB = 0; */
|
||||
U8X8_A(199),U8X8_A(0),U8X8_A(0),
|
||||
|
||||
U8X8_C(0x0C), /* BOOSTER_SOFT_START_CONTROL */
|
||||
U8X8_A(0xd7),U8X8_A(0xd6),U8X8_A(0x9d),
|
||||
|
||||
U8X8_CA(0x2c, 0xa8), /* WRITE_VCOM_REGISTER: VCOM 7C */
|
||||
U8X8_CA(0x3a, 0x1a), /* SET_DUMMY_LINE_PERIOD: 4 dummy lines per gate */
|
||||
U8X8_CA(0x3b, 0x08), /* SET_GATE_TIME: 2us per line */
|
||||
U8X8_CA(0x11, 0x03), /* DATA_ENTRY_MODE_SETTING: X increment; Y increment */
|
||||
U8X8_CAA(0x44, 0, 24), /* SET_RAM_X_ADDRESS_START_END_POSITION: LO(x >> 3), LO((w-1) >> 3) */
|
||||
U8X8_CAAAA(0x45, 0, 0, 199&255, 199>>8), /* SET_RAM_Y_ADDRESS_START_END_POSITION: LO(y), HI(y), LO(h - 1), HI(h - 1) */
|
||||
U8X8_CA(0x4e, 0), /* LO(x >> 3) */
|
||||
U8X8_CAA(0x4f, 0, 0), /* LO(y), HI(y >> 8) */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_ssd1607_ws_200x200(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1607_200x200_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_ws_200x200_init_seq);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_200x200_powersave0_seq);
|
||||
u8x8_d_ssd1607_200x200_first_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_ws_to_display_seq);; // to setup LUT
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_200x200_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_200x200_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_d_ssd1607_draw_tile(u8x8, arg_int, arg_ptr);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_REFRESH:
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1607_ws_to_refresh_seq);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
214
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7511.c
Normal file
214
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7511.c
Normal file
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
|
||||
u8x8_d_st7511.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2019, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
20 May 2019:
|
||||
https://github.com/olikraus/u8g2/issues/876
|
||||
Probably HW Flip does not work
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_st7511_320x240_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x015, 0x0a5), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7511_320x240_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x014, 0x0a5), /* display off */
|
||||
// maybe use sleep mode here, but it not clear whether sleep mode will reset all the settings
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7511_320x240_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CAAAA(0x24, 0x01, 0xa5, 0xa5, 0xa5), /* memory control directions */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7511_320x240_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CAAAA(0x24, 0x02, 0xa5, 0xa5, 0xa5), /* memory control directions */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*=====================================================*/
|
||||
/* AV-Display: AVD-TM57QV-NW-001-B, issue 876 */
|
||||
|
||||
static const u8x8_display_info_t u8x8_st7511_320x240_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 150, /* ST7511 Datasheet */
|
||||
/* pre_chip_disable_wait_ns = */ 150, /* ST7511 Datasheet */
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 1,
|
||||
/* sda_setup_time_ns = */ 120, /* ST7511 Datasheet */
|
||||
/* sck_pulse_width_ns = */ 150, /* ST7511 Datasheet */
|
||||
/* sck_clock_hz = */ 3300000UL, /* ST7511 Datasheet: 300ns cycle */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 200, /* */
|
||||
/* write_pulse_width_ns = */ 250, /* ST7511 Datasheet: 500ns */
|
||||
/* tile_width = */ 40, /* width of 17*8=136 pixel */
|
||||
/* tile_hight = */ 30,
|
||||
/* default_x_offset = */ 160,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 320,
|
||||
/* pixel_height = */ 240
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7511_320x240_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_CA(0xae, 0xa5), /* SW Reset */
|
||||
U8X8_CAAAA(0x61, 0x0f, 0x04, 0x02, 0xa5), /* all power on */
|
||||
U8X8_CAAAA(0x62, 0x0a, 0x06, 0x0f, 0xa5), /* electronic volumne set 1 */
|
||||
U8X8_CAAAA(0x63, 0x0f, 0x0f, 0xa5, 0xa5), /* electronic volumne set 2 */
|
||||
U8X8_CAAAA(0x66, 0x00, 0xa5, 0xa5, 0xa5), /* electronic volumne set 2 */
|
||||
U8X8_CA(0x12, 0xa5), /* SLeeP OUT */
|
||||
U8X8_DLY(50),
|
||||
// skiping display on here, deviation from https://github.com/olikraus/u8g2/issues/876
|
||||
// will be called later in u8x8_d_st7511_320x240_powersave0_seq
|
||||
U8X8_CAAAA(0x22, 0x00, 0xa5, 0xa5, 0xa5), /* monochrome display */
|
||||
U8X8_CAAAA(0x24, 0x01, 0xa5, 0xa5, 0xa5), /* memory control directions */
|
||||
|
||||
U8X8_DLY(50),
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_st7511_avd_320x240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint16_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7511_320x240_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7511_320x240_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7511_320x240_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7511_320x240_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7511_320x240_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7511_320x240_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
// not sure how to implement this....
|
||||
// u8x8_cad_StartTransfer(u8x8);
|
||||
// u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
// set page
|
||||
u8x8_cad_SendCmd(u8x8, 0x025);
|
||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
u8x8_cad_SendArg(u8x8, 0x09f); // end page
|
||||
u8x8_cad_SendArg(u8x8, 0x000); // frame 0
|
||||
u8x8_cad_SendArg(u8x8, 0x0a5);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
// set column
|
||||
u8x8_cad_SendCmd(u8x8, 0x026);
|
||||
u8x8_cad_SendArg(u8x8, (x>>8) );
|
||||
u8x8_cad_SendArg(u8x8, (x&255) );
|
||||
u8x8_cad_SendArg(u8x8, 0x002);
|
||||
u8x8_cad_SendArg(u8x8, 0x07f);
|
||||
|
||||
// start data transfer
|
||||
u8x8_cad_SendCmd(u8x8, 0x02c);
|
||||
u8x8_cad_SendArg(u8x8, 0x0a5 );
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
|
||||
while ( c > 128 )
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 128, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
c -= 128;
|
||||
ptr += 128;
|
||||
}
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
354
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st75160.c
Normal file
354
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st75160.c
Normal file
@@ -0,0 +1,354 @@
|
||||
/*
|
||||
|
||||
u8x8_d_st75160.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2021, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
https://github.com/olikraus/u8g2/issues/1642
|
||||
|
||||
|
||||
0x030 ext 00
|
||||
0x031 ext 01
|
||||
0x038 ext 10
|
||||
0x039 ext 11
|
||||
|
||||
cad 011
|
||||
|
||||
|
||||
code examples:
|
||||
http://www.it610.com/article/2601023.htm
|
||||
|
||||
normal mode:
|
||||
0x00c bit format
|
||||
U8X8_CA( 0xbc, 0x00 ), data scan dir
|
||||
U8X8_A( 0xa6 ),
|
||||
y: 0 offset
|
||||
|
||||
flip mode:
|
||||
0x008 bit format
|
||||
U8X8_CA( 0xbc, 0x03 ), data scan dir
|
||||
U8X8_A( 0xa6 ),
|
||||
y: 5 offset
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
/* not a real power down for the st75256... just a display off */
|
||||
static const uint8_t u8x8_d_st75256_256x128_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_C( 0x94 ), /* sleep out */
|
||||
U8X8_DLY(10),
|
||||
U8X8_C( 0xaf ), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st75256_256x128_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_C( 0xae ), /* display off */
|
||||
U8X8_C( 0x95 ), /* sleep in */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st75256_jlx256128_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_CA( 0xbc, 0x00 ), /* data scan dir */
|
||||
U8X8_A( 0xa6 ), /* ??? */
|
||||
|
||||
//U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_C( 0x00c ), /* data format LSB top */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st75256_jlx256128_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_CA( 0xbc, 0x03 ), /* data scan dir */
|
||||
U8X8_A( 0xa6 ), /* ??? */
|
||||
|
||||
//U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_C( 0x008 ), /* data format MSB top */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st75256_jlx172104_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_CA( 0xbc, 0x02 ), /* data scan dir */
|
||||
U8X8_A( 0xa6 ), /* ??? */
|
||||
|
||||
//U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_C( 0x00c ), /* data format LSB top */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st75256_jlx172104_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_CA( 0xbc, 0x01 ), /* data scan dir */
|
||||
U8X8_A( 0xa6 ), /* ??? */
|
||||
|
||||
//U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_C( 0x008 ), /* data format MSB top */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st75256_jlx256160_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_CA( 0xbc, 0x00 ), /* data scan dir */
|
||||
U8X8_A( 0xa6 ), /* ??? */
|
||||
|
||||
//U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_C( 0x00c ), /* data format LSB top */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st75256_jlx256160_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_CA( 0xbc, 0x03 ), /* data scan dir */
|
||||
U8X8_A( 0xa6 ), /* ??? */
|
||||
|
||||
//U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_C( 0x008 ), /* data format MSB top */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*=============================================*/
|
||||
/* JM16096 https://github.com/olikraus/u8g2/issues/1642 */
|
||||
|
||||
static const u8x8_display_info_t u8x8_st75160_jm16096_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 5,
|
||||
/* post_reset_wait_ms = */ 5, /**/
|
||||
/* sda_setup_time_ns = */ 20, /* */
|
||||
/* sck_pulse_width_ns = */ 40, /* */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4, /* 400KHz */
|
||||
/* data_setup_time_ns = */ 15,
|
||||
/* write_pulse_width_ns = */ 70,
|
||||
/* tile_width = */ 20,
|
||||
/* tile_hight = */ 12,
|
||||
/* default_x_offset = */ 0, /* x offset in flipmode 0 */
|
||||
/* flipmode_x_offset = */ 0, /* */
|
||||
/* pixel_width = */ 160,
|
||||
/* pixel_height = */ 96
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_st75160_jm16096_init_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_DLY(20),
|
||||
|
||||
U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_C( 0x094 ), /* sleep out */
|
||||
|
||||
//U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_C( 0x0ae ), /* display off */
|
||||
|
||||
U8X8_C( 0x031 ), /* select 01 commands */
|
||||
U8X8_CA( 0x0d7, 0x09f ), /* disable auto read */
|
||||
|
||||
//U8X8_C( 0x031 ), /* select 01 commands */
|
||||
U8X8_C( 0x032 ), /* analog circuit set */
|
||||
U8X8_A( 0x000 ), /* code example: OSC Frequency adjustment */
|
||||
U8X8_A( 0x001 ), /* Frequency on booster capacitors 1 = 6KHz? */
|
||||
U8X8_A( 0x004 ), /* Bias: 1: 1/13, 2: 1/12, 3: 1/11, 4:1/10, 5:1/9 */
|
||||
|
||||
//U8X8_C( 0x031 ), /* select 01 commands */
|
||||
U8X8_C( 0x020 ), /* gray levels */
|
||||
U8X8_A( 0x01 ),
|
||||
U8X8_A( 0x03 ),
|
||||
U8X8_A( 0x05 ),
|
||||
U8X8_A( 0x07 ),
|
||||
U8X8_A( 0x09),
|
||||
U8X8_A( 0x0b ),
|
||||
U8X8_A( 0x0d ),
|
||||
U8X8_A( 0x10 ),
|
||||
U8X8_A( 0x11 ),
|
||||
U8X8_A( 0x13 ),
|
||||
U8X8_A( 0x15 ),
|
||||
U8X8_A( 0x17 ),
|
||||
U8X8_A( 0x19 ),
|
||||
U8X8_A( 0x1b ),
|
||||
U8X8_A( 0x1d ),
|
||||
U8X8_A( 0x1f ),
|
||||
|
||||
|
||||
U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_CAA(0x75, 0, 0x4f), /* row range */
|
||||
U8X8_CAA(0x15, 0, 239), /* col range */
|
||||
|
||||
//U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_CA( 0xbc, 0x02 ), /* data scan dir */
|
||||
U8X8_A( 0xa6 ), /* ??? */
|
||||
|
||||
//U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_C( 0x00c ), /* data format LSB top */
|
||||
|
||||
//U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_C( 0xca ), /* display control, 3 args follow */
|
||||
U8X8_A( 0x00 ), /* 0x00: no clock division, 0x04: devide clock */
|
||||
U8X8_A( 95 ), /* 1/96 duty */
|
||||
U8X8_A( 0x20 ), /* nline off */
|
||||
|
||||
//U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_CA( 0x0f0, 0x010 ), /* monochrome mode = 0x010*/
|
||||
|
||||
//U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_CAA( 0x81, 0x18, 0x04 ), /* Volume control */
|
||||
|
||||
//U8X8_C( 0x030 ), /* select 00 commands */
|
||||
U8X8_CA( 0x020, 0x00b ), /* Power control: Regulator, follower & booster on */
|
||||
U8X8_DLY(100),
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_st75160_jm16096(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x030 ); /* select command set */
|
||||
u8x8_cad_SendCmd(u8x8, 0x075 ); /* row */
|
||||
if ( u8x8->x_offset == 0 ) /* 0 means flip mode 1 */
|
||||
u8x8_cad_SendArg(u8x8, 1+(((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
else
|
||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
u8x8_cad_SendArg(u8x8, 0x04f);
|
||||
//u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
u8x8_cad_SendCmd(u8x8, 0x015 ); /* col */
|
||||
u8x8_cad_SendArg(u8x8, x+u8x8->x_offset);
|
||||
u8x8_cad_SendArg(u8x8, 255);
|
||||
u8x8_cad_SendCmd(u8x8, 0x05c );
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
c *= 8;
|
||||
|
||||
if ( c + x > 160u )
|
||||
{
|
||||
c = 160u;
|
||||
c -= x;
|
||||
}
|
||||
|
||||
u8x8_cad_SendData(u8x8, c, ptr);
|
||||
x += c;
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
return 1;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
//u8x8_SetI2CAddress(u8x8, 0x078); /* lowest I2C adr of the ST75256 */
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st75160_jm16096_display_info);
|
||||
return 1;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st75160_jm16096_init_seq);
|
||||
return 1;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave1_seq);
|
||||
|
||||
return 1;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
return 1;
|
||||
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x030 );
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 ); /* there are 9 bit for the volume control */
|
||||
u8x8_cad_SendArg(u8x8, (arg_int & 0x1f)<<1 ); /* lower 6 bit */
|
||||
u8x8_cad_SendArg(u8x8, (arg_int>>5)); /* upper 3 bit */
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
1776
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st75256.c
Normal file
1776
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st75256.c
Normal file
File diff suppressed because it is too large
Load Diff
462
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7528.c
Normal file
462
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7528.c
Normal file
@@ -0,0 +1,462 @@
|
||||
/*
|
||||
|
||||
u8x8_d_st7528.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2019, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
ST7528: 16 Graylevel Controller
|
||||
https://github.com/olikraus/u8g2/issues/986
|
||||
I2C Address: 0x03f (0x7e)
|
||||
|
||||
|
||||
ERC16004
|
||||
https://www.buydisplay.com/default/2-inch-lcd-160x64-graphic-module-serial-spi-display-st7528-black-on-white
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_st7528_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x038, 0x074), /* ext mode 0*/
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7528_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x038, 0x074), /* ext mode 0*/
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7528_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* ADC */
|
||||
U8X8_C(0x0c8), /* SHL */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7528_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* ADC */
|
||||
U8X8_C(0x0c0), /* SHL */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
input:
|
||||
one tile (8 Bytes)
|
||||
output:
|
||||
Tile for st7528 (32 Bytes)
|
||||
*/
|
||||
|
||||
static uint8_t u8x8_st7528_8to32_dest_buf[32];
|
||||
|
||||
static uint8_t *u8x8_st7528_8to32(U8X8_UNUSED u8x8_t *u8x8, uint8_t *ptr)
|
||||
{
|
||||
uint8_t j;
|
||||
uint8_t *dest;
|
||||
|
||||
dest = u8x8_st7528_8to32_dest_buf;
|
||||
for( j = 0; j < 8; j++ )
|
||||
{
|
||||
*dest++ =*ptr;
|
||||
*dest++ =*ptr;
|
||||
*dest++ =*ptr;
|
||||
*dest++ =*ptr;
|
||||
ptr++;
|
||||
}
|
||||
return u8x8_st7528_8to32_dest_buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static uint8_t u8x8_d_st7528_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x;
|
||||
uint8_t y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7528_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7528_nhd_c160100_init_seq);
|
||||
*/
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7528_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7528_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7528_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7528_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1326 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8; // not clear
|
||||
|
||||
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendCmd(u8x8, 0xb0 | y ); /* set page address */
|
||||
u8x8_cad_SendCmd(u8x8, 0x10| (x>>4) ); /* set col msb*/
|
||||
u8x8_cad_SendCmd(u8x8, 0x00| (x&15) ); /* set col lsb*/
|
||||
|
||||
u8x8_cad_SendData(u8x8, 32, u8x8_st7528_8to32(u8x8, ptr));
|
||||
|
||||
ptr += 8;
|
||||
x += 8;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static void u8x8_d_st7528_graylevel_init(u8x8_t *u8x8, uint8_t mode0)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x38 );
|
||||
u8x8_cad_SendArg(u8x8, mode0+1 );
|
||||
for( i = 0; i < 64; i++ )
|
||||
{
|
||||
u8x8_cad_SendCmd(u8x8, i+0x080 );
|
||||
u8x8_cad_SendArg(u8x8, i & 0xfc);
|
||||
}
|
||||
u8x8_cad_SendCmd(u8x8, 0x38 );
|
||||
u8x8_cad_SendArg(u8x8, mode0 );
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
}
|
||||
|
||||
/*===============================================================*/
|
||||
/* NHD C160100 */
|
||||
static const uint8_t u8x8_d_st7528_nhd_c160100_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
/*
|
||||
I2C_out(0x48);//partial display duty ratio
|
||||
I2C_out(0x64);// 1/100 duty
|
||||
I2C_out(0xA0);//ADC select
|
||||
I2C_out(0xC8);//SHL select
|
||||
I2C_out(0x44);//initial Com0 register
|
||||
I2C_out(0x00);//scan from Com0
|
||||
I2C_out(0xAB);//OSC on
|
||||
I2C_out(0x26);//
|
||||
I2C_out(0x81); //set electronic volume
|
||||
I2C_out(0x15);//vopcode=0x1C
|
||||
I2C_out(0x56);//set 1/11 bias
|
||||
I2C_out(0x64);//3x
|
||||
delay(2);
|
||||
I2C_out(0x2C);//
|
||||
I2C_out(0x66);//5x
|
||||
delay(2);
|
||||
I2C_out(0x2E);//
|
||||
delay(2);
|
||||
I2C_out(0x2F);//power control
|
||||
I2C_out(0xF3);//bias save circuit
|
||||
I2C_out(0x00);//
|
||||
I2C_out(0x96);//frc and pwm
|
||||
I2C_out(0x38);//external mode
|
||||
I2C_out(0x75);//
|
||||
I2C_out(0x97);//3frc, 45 pwm THIS IS A MODE0 CMD, IT IS USELESS HERE
|
||||
I2C_out(0x80);//start 16-level grayscale settings
|
||||
*/
|
||||
U8X8_CA(0x038, 0x064), /* ext mode 0*/
|
||||
U8X8_CA(0x048, 0x064), /* partial display duty ratio, 1/100 duty*/
|
||||
U8X8_C(0x0a0), /* ADC */
|
||||
U8X8_C(0x0c8), /* SHL */
|
||||
U8X8_CA(0x044, 0x000), /* initial Com0 */
|
||||
U8X8_C(0x0ab), /* start oscillator */
|
||||
U8X8_C(0x026), /* Select the internal resistance ratio of the regulator resistor */
|
||||
U8X8_CA(0x081, 0x015), /* volumn */
|
||||
U8X8_C(0x056), /* LCD Bias */
|
||||
U8X8_C(0x064), /* DC DC step up */
|
||||
U8X8_DLY(2),
|
||||
U8X8_C(0x02c), /* Power Control */
|
||||
U8X8_C(0x066), /* DC DC step up */
|
||||
U8X8_DLY(2),
|
||||
U8X8_C(0x02e), /* Power Control */
|
||||
U8X8_DLY(2),
|
||||
U8X8_C(0x02f), /* Power Control */
|
||||
U8X8_CA(0x0f3, 0x000), /* bias power save */
|
||||
U8X8_C(0x096), /* frc and pwm */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_st7528_160x100_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 5,
|
||||
/* post_reset_wait_ms = */ 5, /**/
|
||||
/* sda_setup_time_ns = */ 20, /* st7528 */
|
||||
/* sck_pulse_width_ns = */ 25, /* st7528 */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* st7528 actually allows 20MHz according to the datasheet */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 80, /* st7528 */
|
||||
/* tile_width = */ 20,
|
||||
/* tile_hight = */ 13,
|
||||
/* default_x_offset = */ 0, /* x_offset is used as y offset for the ssd1326 */
|
||||
/* flipmode_x_offset = */ 0, /* x_offset is used as y offset for the ssd1326 */
|
||||
/* pixel_width = */ 160,
|
||||
/* pixel_height = */ 100
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_st7528_nhd_c160100(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7528_160x100_display_info);
|
||||
return 1;
|
||||
}
|
||||
if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7528_nhd_c160100_init_seq);
|
||||
u8x8_d_st7528_graylevel_init(u8x8, 0x074);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_st7528_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
/*===============================================================*/
|
||||
/* ERC16064, https://www.buydisplay.com/2-inch-lcd-160x64-graphic-module-serial-spi-display-st7528-black-on-white */
|
||||
|
||||
/*
|
||||
|
||||
#define ModeSet 0x38
|
||||
#define ModeSetP1 0x64 //EXT=0
|
||||
#define ModeSetP2 0x65 //EXT=1
|
||||
|
||||
#define Display_on 0xaf
|
||||
#define Display_off 0xae
|
||||
|
||||
#define Regulator 0x26
|
||||
#define Contrast_level 0x81
|
||||
#define PowerControll_on1 0x2c
|
||||
#define PowerControll_on2 0x2e
|
||||
#define PowerControll_on3 0x2f
|
||||
|
||||
#define LcdBias_9 0x54
|
||||
#define InterOsc_on 0xab
|
||||
#define EntireDisp_on 0xa5
|
||||
#define EntireDisp_off 0xa4
|
||||
#define BoostLevel_5 0x66
|
||||
#define Duty_set 0x48
|
||||
#define Duty_setP 0x40
|
||||
#define Start_columnlsb 0x00
|
||||
#define Start_columnmsb 0x10
|
||||
#define Start_page 0xb0
|
||||
#define StartLine_set 0x40
|
||||
//#define StartLine_setP 0x00
|
||||
#define Set_Initial_COM0 0x44
|
||||
#define Set_Initial_COM0P 0x12
|
||||
|
||||
|
||||
#define Entire_Displa_ON 0xA5
|
||||
#define Entire_Displa_OFF 0xA4
|
||||
|
||||
#define FrcPwm_set 0x92
|
||||
#define NLineInversion_on 0x4c
|
||||
#define NLineInversion_onP 0x1f
|
||||
#define NLineInversion_off 0xe4
|
||||
#define ReverseDisp_on 0xa7
|
||||
#define ReverseDisp_off 0xa6
|
||||
#define AdcSelect 0xa0
|
||||
#define ComScanDirection 0xc8
|
||||
|
||||
Write_command(ModeSet); 0x38, 0x64
|
||||
Write_command(ModeSetP1);
|
||||
Write_command(InterOsc_on); 0xab
|
||||
Write_command(Set_Initial_COM0); 0x44, 0x12
|
||||
Write_command(Set_Initial_COM0P);
|
||||
|
||||
Write_command(AdcSelect); 0xa0
|
||||
Write_command(ComScanDirection); 0xc8
|
||||
Write_command(BoostLevel_5); 0x66
|
||||
Delay(1000);
|
||||
Write_command(LcdBias_9); 0x54
|
||||
Write_command(Duty_set); 0x48, 0x40
|
||||
Write_command(Duty_setP);
|
||||
Write_command(Regulator); 0x26
|
||||
Write_command(Contrast_level); 0x81, 0x0b
|
||||
Write_command(Contrast_levelP);
|
||||
Write_command(PowerControll_on1); 0x2c
|
||||
Delay(10000);
|
||||
Write_command(PowerControll_on2); 0x2e
|
||||
Delay(1000);
|
||||
Write_command(PowerControll_on3); 0x2f
|
||||
Delay(1000);
|
||||
Write_command(FrcPwm_set); 0x92
|
||||
|
||||
Write_command(ModeSet);
|
||||
Write_command(ModeSetP2);
|
||||
for(i=0;i<64;i++)
|
||||
{
|
||||
Write_command(0x80+i);
|
||||
Write_command(Gray_Parameters[i]);
|
||||
}
|
||||
Write_command(ModeSet);
|
||||
Write_command(ModeSetP1);
|
||||
*/
|
||||
|
||||
static const uint8_t u8x8_d_st7528_erc16064_init_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x038, 0x064), /* ext mode 0*/
|
||||
U8X8_C(0x0ab), /* start oscillator */
|
||||
U8X8_CA(0x044, 0x012), /* initial Com0 */
|
||||
U8X8_C(0x0a0), /* ADC */
|
||||
U8X8_C(0x0c8), /* SHL */
|
||||
U8X8_C(0x066), /* boost level, ERC16064: 0x066 */
|
||||
U8X8_DLY(1),
|
||||
U8X8_C(0x054), /* LCD Bias, ERC16064: 0x054 */
|
||||
U8X8_CA(0x048, 0x040), /* partial display duty ratio */
|
||||
U8X8_C(0x026), /* Select the internal resistance ratio of the regulator resistor */
|
||||
U8X8_CA(0x081, 0x00b), /* contrast, ERC16064: 0x00b */
|
||||
|
||||
U8X8_C(0x02c), /* Power Control */
|
||||
U8X8_DLY(2),
|
||||
U8X8_C(0x02e), /* Power Control */
|
||||
U8X8_DLY(2),
|
||||
U8X8_C(0x02f), /* Power Control */
|
||||
U8X8_DLY(2),
|
||||
U8X8_C(0x092), /* frc and pwm, ERC160624: 0x092 */
|
||||
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_st7528_erc16064_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 5,
|
||||
/* post_reset_wait_ms = */ 5, /**/
|
||||
/* sda_setup_time_ns = */ 20, /* st7528 */
|
||||
/* sck_pulse_width_ns = */ 25, /* st7528 */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* st7528 actually allows 20MHz according to the datasheet */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 80, /* st7528 */
|
||||
/* tile_width = */ 20,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0, /* x_offset is used as y offset for the ssd1326 */
|
||||
/* flipmode_x_offset = */ 0, /* x_offset is used as y offset for the ssd1326 */
|
||||
/* pixel_width = */ 160,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_st7528_erc16064(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7528_erc16064_display_info);
|
||||
return 1;
|
||||
}
|
||||
if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7528_erc16064_init_seq);
|
||||
u8x8_d_st7528_graylevel_init(u8x8, 0x064);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_st7528_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
271
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st75320.c
Normal file
271
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st75320.c
Normal file
@@ -0,0 +1,271 @@
|
||||
/*
|
||||
|
||||
u8x8_d_st75320.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2019, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
ST75320: 320x240 monochrome LCD
|
||||
|
||||
https://github.com/olikraus/u8g2/issues/921
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
static const uint8_t u8x8_d_st75320_jlx320240_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st75320_jlx320240_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st75320_jlx320240_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0xC4, 0x02), /* COM Output Status, Bits 0 & 1 */
|
||||
U8X8_C(0xA1), /* Column Address Direction: Bit 0 */
|
||||
//U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
//U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st75320_jlx320240_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
//U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
//U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_CA(0xC4, 0x03), /* COM Output Status, Bits 0 & 1 */
|
||||
U8X8_C(0xA0), /* Column Address Direction: Bit 0 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/*===================================================*/
|
||||
|
||||
static uint8_t u8x8_d_st75320_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint16_t x;
|
||||
uint8_t c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st75320_jlx320240_display_info);
|
||||
break;
|
||||
*/
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st75320_jlx320240_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st75320_jlx320240_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st75320_jlx320240_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st75320_jlx320240_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st75320_jlx320240_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int<<2 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int>>6 );
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x013);
|
||||
u8x8_cad_SendArg(u8x8, (x>>8) );
|
||||
u8x8_cad_SendArg(u8x8, (x&255) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b1 );
|
||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x01d ); // write data
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
/* SendData can not handle more than 255 bytes */
|
||||
if ( c > 31 )
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 248, ptr); /* 31*8=248 */
|
||||
ptr+=248;
|
||||
c -= 31;
|
||||
}
|
||||
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr);
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*===================================================*/
|
||||
|
||||
|
||||
/* QT-2832TSWUG02/ZJY-2832TSWZG02 */
|
||||
static const uint8_t u8x8_d_st75320_jlx320240_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0xAE), // Display OFF
|
||||
U8X8_CA(0xEA, 0x00), // Power Discharge Control, Discharge OFF
|
||||
U8X8_C(0xA8), // sleep out
|
||||
U8X8_C(0xAB), // OSC ON
|
||||
U8X8_C(0x69), // Temperature Detection ON
|
||||
U8X8_C(0x4E), // TC Setting
|
||||
U8X8_A8(0xff, 0x44, 0x12, 0x11, 0x11, 0x11, 0x22, 0x23),
|
||||
U8X8_CAA(0x39, 0x00, 0x00), //TC Flag
|
||||
|
||||
|
||||
U8X8_CA(0x2B, 0x00), // Frame Rate Level
|
||||
U8X8_CAA(0x5F, 0x66, 0x66), // Set Frame Frequency, fFR=80Hz in all temperature range
|
||||
U8X8_CAAA(0xEC, 0x19, 0x64, 0x6e), // FR Compensation Temp. Range, TA = -15 degree, TB = 60 degree, TC = 70 degree
|
||||
U8X8_CAA(0xED, 0x04, 0x04), // Temp. Hysteresis Value (thermal sensitivity)
|
||||
U8X8_C(0xA6), // Display Inverse OFF
|
||||
U8X8_C(0xA4), // Disable Display All Pixel ON
|
||||
|
||||
U8X8_CA(0xC4, 0x02), // COM Output Status
|
||||
U8X8_C(0xA1), // Column Address Direction: MX=0
|
||||
|
||||
U8X8_CAA(0x6D, 0x07, 0x00), // Display Area, Duty = 1/240 duty, Start Group = 1
|
||||
U8X8_C(0x84), // Display Data Input Direction: Column
|
||||
U8X8_CA(0x36, 0x1e), // Set N-Line
|
||||
U8X8_C(0xE4), // N-Line On
|
||||
U8X8_CA(0xE7, 0x19), // LCD Drive Method //NLFR=1//
|
||||
|
||||
U8X8_CAA(0x81, 0x4f, 0x01), // OX81: Set EV=64h, 0..255, 0..3
|
||||
U8X8_CA(0xA2, 0x0a), // BIAS //1/16 BIAS
|
||||
U8X8_CA(0x25, 0x020), // Power Control //AVDD ON
|
||||
U8X8_DLY(10),
|
||||
U8X8_CA(0x25, 0x60), // Power Control//AVDD, MV3 & NAVDD ON
|
||||
U8X8_DLY(10),
|
||||
U8X8_CA(0x25, 0x70), // Power Control //AVDD, MV3, NAVDD & V3 ON
|
||||
U8X8_DLY(10),
|
||||
U8X8_CA(0x25, 0x78), // Power Control//AVDD, MV3, NAVDD, V3 & VPF ON
|
||||
U8X8_DLY(10),
|
||||
U8X8_CA(0x25, 0x7c), // Power Control//AVDD, MV3, NAVDD, V3, VPF & VNF ON
|
||||
U8X8_DLY(10),
|
||||
U8X8_CA(0x25, 0x7e), // Power Control//VOUT, AVDD, MV3, NAVDD, V3, VPF & VNF ON
|
||||
U8X8_DLY(10),
|
||||
U8X8_CA(0x25, 0x7f), // Power Control/VOUT, AVDD, MV3, NAVDD, V3, VPF & VNF ON
|
||||
U8X8_DLY(10),
|
||||
//U8X8_C(0xaf); //Display ON
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_st75320_jlx320240_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 5,
|
||||
/* post_reset_wait_ms = */ 5, /**/
|
||||
/* sda_setup_time_ns = */ 20, /* */
|
||||
/* sck_pulse_width_ns = */ 40, /* */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4, /* 400KHz */
|
||||
/* data_setup_time_ns = */ 15,
|
||||
/* write_pulse_width_ns = */ 70,
|
||||
/* tile_width = */ 40,
|
||||
/* tile_hight = */ 30,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 320,
|
||||
/* pixel_height = */ 240
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_st75320_jlx320240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_st75320_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st75320_jlx320240_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st75320_jlx320240_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
1281
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7565.c
Normal file
1281
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7565.c
Normal file
File diff suppressed because it is too large
Load Diff
1163
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7567.c
Normal file
1163
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7567.c
Normal file
File diff suppressed because it is too large
Load Diff
360
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7571.c
Normal file
360
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7571.c
Normal file
@@ -0,0 +1,360 @@
|
||||
/*
|
||||
|
||||
u8x8_d_st7571.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2020, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
ST7571: 128x129 2-bit graylevel LCD
|
||||
|
||||
https://github.com/olikraus/u8g2/issues/921
|
||||
https://github.com/olikraus/u8g2/issues/1575 128x96
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
static const uint8_t u8x8_d_st7571_128x128_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x071), /* exit power save mode */
|
||||
U8X8_C(0x0a8), /* disable powersave mode */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7571_128x128_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_C(0x0a9), /* enter powersave mode */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7571_128x128_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7571_128x128_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/*===================================================*/
|
||||
|
||||
static uint8_t u8x8_d_st7571_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint16_t x;
|
||||
uint8_t c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7571_128x128_display_info);
|
||||
break;
|
||||
*/
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7571_128x128_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7571_128x128_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7571_128x128_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7571_128x128_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7571_128x128_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int>>2); // 6 bit for the ST7571
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
/* SendData can not handle more than 255 bytes */
|
||||
/*
|
||||
if ( c > 31 )
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 31*8, ptr);
|
||||
ptr+=31*8;
|
||||
c -= 31;
|
||||
}
|
||||
*/
|
||||
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr);
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*===================================================*/
|
||||
|
||||
|
||||
/* QT-2832TSWUG02/ZJY-2832TSWZG02 */
|
||||
static const uint8_t u8x8_d_st7571_128x128_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0xAE), // Display OFF
|
||||
U8X8_C(0x38), // Mode Set
|
||||
U8X8_C(0xB8), // FR=1011 (85Hz), BE[1:0]=10, level 3 booster
|
||||
|
||||
|
||||
U8X8_C(0xA0), // ADC select
|
||||
U8X8_C(0xC8), // SHL select
|
||||
U8X8_CA(0x44, 0x00), // COM0 register
|
||||
U8X8_CA(0x40, 0x7f), // initial display line (0x7f... strange but ok... maybe specific for the JLX128128)
|
||||
// 2 sep 2021: maybe this also wrong because the 0x44 command is overwritten later.
|
||||
|
||||
U8X8_C(0xAB), // OSC ON
|
||||
U8X8_C(0x25), // Voltage regulator
|
||||
U8X8_CA(0x81, 0x33), // Volume
|
||||
U8X8_C(0x54), // LCD Bias: 0x056=1/11 (1/11 according to JLX128128 datasheet), 0x054=1/9
|
||||
U8X8_CA(0x44, 0x7f), // Duty 1/128 // 2 Sep 2021: Should this be 00x48???
|
||||
|
||||
U8X8_C(0x2C), // Power Control, VC: ON, VR: OFF, VF: OFF
|
||||
U8X8_DLY(200),
|
||||
U8X8_C(0x2E), // Power Control, VC: ON, VR: ON, VF: OFF
|
||||
U8X8_DLY(200),
|
||||
U8X8_C(0x2F), // Power Control, VC: ON, VR: ON, VF: ON
|
||||
U8X8_DLY(10),
|
||||
|
||||
U8X8_C(0x7B), // command set 3
|
||||
U8X8_C(0x11), // black white mode
|
||||
U8X8_C(0x00), // exit command set 3
|
||||
|
||||
|
||||
U8X8_C(0xA6), // Display Inverse OFF
|
||||
U8X8_C(0xA4), // Disable Display All Pixel ON
|
||||
|
||||
//U8X8_C(0xAF), // Display on
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_st7571_128x128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 5,
|
||||
/* post_reset_wait_ms = */ 5, /**/
|
||||
/* sda_setup_time_ns = */ 20, /* */
|
||||
/* sck_pulse_width_ns = */ 40, /* */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4, /* 400KHz */
|
||||
/* data_setup_time_ns = */ 15,
|
||||
/* write_pulse_width_ns = */ 70,
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_st7571_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_st7571_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7571_128x128_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7571_128x128_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*===================================================*/
|
||||
/*
|
||||
https://github.com/olikraus/u8g2/issues/1575
|
||||
http://www.jlxlcd.cn/html/zh-detail-1211.html
|
||||
*/
|
||||
static const uint8_t u8x8_d_st7571_128x96_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
|
||||
U8X8_C(0xAE), // Display OFF
|
||||
U8X8_C(0x38), // Mode Set
|
||||
//U8X8_C(0xB8), // FR=1011 (85Hz), BE[1:0]=10, level 3 booster
|
||||
U8X8_C(0x94), // 128x96: 75 Hz
|
||||
|
||||
U8X8_C(0xA0), // ADC select
|
||||
U8X8_C(0xC8), // SHL select
|
||||
U8X8_CA(0x44, 0x20), // 128x96: COM0 register
|
||||
U8X8_CA(0x40, 0x00), // 128x96 datasheet
|
||||
|
||||
U8X8_C(0xAB), // OSC ON
|
||||
U8X8_C(0x27), // 128x96: Voltage regulator
|
||||
U8X8_CA(0x81, 0x28), // 128x96: Volume
|
||||
U8X8_C(0x57), // 128x96: LCD Bias: 1/12
|
||||
U8X8_CA(0x48, 0x61), // 128x96: Duty 1/96
|
||||
|
||||
U8X8_C(0x2C), // Power Control, VC: ON, VR: OFF, VF: OFF
|
||||
U8X8_DLY(200),
|
||||
U8X8_C(0x2E), // Power Control, VC: ON, VR: ON, VF: OFF
|
||||
U8X8_DLY(200),
|
||||
U8X8_C(0x2F), // Power Control, VC: ON, VR: ON, VF: ON
|
||||
U8X8_DLY(10),
|
||||
|
||||
U8X8_C(0x7B), // command set 3
|
||||
U8X8_C(0x11), // black white mode
|
||||
U8X8_C(0x00), // exit command set 3
|
||||
|
||||
|
||||
U8X8_C(0xA6), // Display Inverse OFF
|
||||
U8X8_C(0xA4), // Disable Display All Pixel ON
|
||||
|
||||
//U8X8_C(0xAF), // Display on
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_st7571_128x96_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 5,
|
||||
/* post_reset_wait_ms = */ 5, /**/
|
||||
/* sda_setup_time_ns = */ 20, /* */
|
||||
/* sck_pulse_width_ns = */ 40, /* */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4, /* 400KHz */
|
||||
/* data_setup_time_ns = */ 15,
|
||||
/* write_pulse_width_ns = */ 70,
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 12,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 96
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_st7571_128x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
if ( u8x8_d_st7571_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7571_128x96_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7571_128x96_display_info);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
261
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7586s_erc240160.c
Normal file
261
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7586s_erc240160.c
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
u8x8_d_st7586s_erc240160.c
|
||||
|
||||
Display: 240x160 pixel
|
||||
ST7586s: 384 x 160 x 2
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2018, olikraus@gmail.com
|
||||
|
||||
All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g2.h"
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_st7586s_sleep_on[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x010), /* set power save mode */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7586s_sleep_off[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x011), //Sleep out
|
||||
U8X8_DLY(50), /* delay 50 ms */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7586s_erc240160_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x036), /* Scan Direction Setting */
|
||||
U8X8_A(0x0C8), /* COM159 -> COM0 SEG383 -> SEG0 */
|
||||
U8X8_C(0x037), /* Start line 0 */
|
||||
U8X8_A(0x000),
|
||||
U8X8_C(0x02A), /* Column Address Setting */
|
||||
U8X8_A(0x000), /* COL8 -> COL127 */
|
||||
U8X8_A(0x008),
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x07F), /* 120*3=240 pixels + 120 unused */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7586s_erc240160_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x036), /* Scan Direction Setting */
|
||||
U8X8_A(0x000), /* COM0 -> COM159 SEG0 -> SEG383 */
|
||||
U8X8_C(0x037), /* Start line 0 */
|
||||
U8X8_A(0x000),
|
||||
U8X8_C(0x02A), /* Column Address Setting */
|
||||
U8X8_A(0x000), /* COL0 -> COL119 */
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x000),
|
||||
U8X8_A(0x077), /* 120*3=240 pixels + 120 unused */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7586s_erc240160_init_seq[] = {
|
||||
U8X8_START_TRANSFER(),/* enable chip */
|
||||
U8X8_END_TRANSFER(),/* disable chip */
|
||||
// U8G_ESC_RST(1), /* hardware reset */
|
||||
U8X8_DLY(60), /* Delay 60 ms */
|
||||
U8X8_START_TRANSFER(),/* enable chip */
|
||||
|
||||
U8X8_C(0x001), // Soft reset
|
||||
U8X8_DLY(60), // Delay 120 ms
|
||||
|
||||
U8X8_C(0x011), // Sleep Out
|
||||
U8X8_C(0x028), // Display OFF
|
||||
U8X8_DLY(25), // Delay 50 ms
|
||||
|
||||
U8X8_CAA(0x0C0,0x036,0x01),// Vop = 136h data sheet suggested 0x0145 but this caused streaks
|
||||
|
||||
U8X8_CA(0x0C3,0x000), // BIAS = 1/14
|
||||
|
||||
U8X8_CA(0x0C4,0x007), // Booster = x8
|
||||
|
||||
U8X8_CA(0x0D0,0x01D), // Enable Analog Circuit
|
||||
|
||||
U8X8_CA(0x0B3,0x000), // Set FOSC divider
|
||||
|
||||
U8X8_CA(0x0B5,0x000), // N-Line = 0
|
||||
|
||||
U8X8_C(0x039), // 0x39 Monochrome mode. 0x38 - gray Mode
|
||||
|
||||
U8X8_C(0x03A), // Enable DDRAM Interface
|
||||
U8X8_A(0x002), // monochrome and 4-level
|
||||
|
||||
U8X8_C(0x036), // Scan Direction Setting
|
||||
U8X8_A(0x0C8), // COM:C159->C0 SEG: SEG383->SEG0
|
||||
|
||||
U8X8_C(0x0B1), // First output COM
|
||||
U8X8_A(0x000), //
|
||||
|
||||
U8X8_C(0x0B0), // Duty Setting (num rows - 1)
|
||||
U8X8_A(0x09F),
|
||||
|
||||
U8X8_C(0x020), // Display inversion off
|
||||
|
||||
U8X8_C(0x02A), // Column Address Setting
|
||||
U8X8_A(0x000), // COL0 -> COL127
|
||||
U8X8_A(0x008), //
|
||||
U8X8_A(0x000), //
|
||||
U8X8_A(0x07F), // 80*3=240 pixels
|
||||
|
||||
U8X8_C(0x02B), // Row Address Setting
|
||||
U8X8_A(0x000), // ROW0 -> ROW159
|
||||
U8X8_A(0x000), //
|
||||
U8X8_A(0x000), //
|
||||
U8X8_A(0x09F), // 160 pixels
|
||||
|
||||
U8X8_C(0x029), // Display ON
|
||||
U8X8_END_TRANSFER(),/* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const u8x8_display_info_t u8x8_st7586s_erc240160_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 5,
|
||||
/* pre_chip_disable_wait_ns = */ 5,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 20,
|
||||
/* sck_pulse_width_ns = */ 100, /* datasheet ST7586S */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* ST7586+Atmega128RFA1 works with 8MHz */
|
||||
/* spi_mode = */ 3, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 20, /* datasheet suggests min 20 */
|
||||
/* write_pulse_width_ns = */ 40,
|
||||
/* tile_width = */ 30,
|
||||
/* tile_height = */ 20,
|
||||
/* default_x_offset = */ 0, /* abused as flag to know if we are flipped */
|
||||
/* flipmode_x_offset = */ 1, /* as pixel order different for normal/flipped */
|
||||
/* pixel_width = */ 240,
|
||||
/* pixel_height = */ 160
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* st7586s_erc240160 driver. ST7586 based display from buydisplay.com
|
||||
******************************************************************************/
|
||||
uint8_t u8x8_d_st7586s_erc240160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) {
|
||||
|
||||
uint8_t c;
|
||||
uint8_t *ptr;
|
||||
uint8_t i, byte;
|
||||
uint32_t input;
|
||||
uint8_t output[4];
|
||||
switch (msg) {
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8); // OK Start transfer
|
||||
u8x8_cad_SendCmd(u8x8, 0x02B); /* Row Address Setting */
|
||||
u8x8_cad_SendArg(u8x8, 0x000);
|
||||
u8x8_cad_SendArg(u8x8, 0x008 * ((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
u8x8_cad_SendArg(u8x8, 0x000);
|
||||
u8x8_cad_SendArg(u8x8, 0x09F); // should set end row based on display dimensions
|
||||
u8x8_cad_SendCmd(u8x8, 0x02C); /* cmd write display data to ram */
|
||||
c = ((u8x8_tile_t *) arg_ptr)->cnt; //
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *) arg_ptr)->tile_ptr; //
|
||||
|
||||
// The ST7586S has an unusual 3 pixels per byte format the ERC240160 is even more annoying
|
||||
// as it has every 3rd COM line disconnected for extra oddness so here we read in a byte
|
||||
// (8 pixels) and pack that into 4 bytes of 2 pixels + 1 unused each. This has to be done
|
||||
// in a different order for flipped, normal UUx11x22 flipped 11x22xUU
|
||||
while (c > 0) {
|
||||
input = ((uint8_t)ptr[0]);
|
||||
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
byte = 0;
|
||||
if (u8x8->x_offset ==0){
|
||||
if (input & 0x80) // if bit 7
|
||||
byte = byte | 0x18; //set pixel 1
|
||||
if (input & 0x40) // if bit 6
|
||||
byte = byte | 0x3; //set pixel 2
|
||||
}
|
||||
if (u8x8->x_offset ==1){
|
||||
if (input & 0x80) // if bit 7
|
||||
byte = byte | 0xC0; //set pixel 1
|
||||
if (input & 0x40) // if bit 6
|
||||
byte = byte | 0x18; //set pixel 2
|
||||
}
|
||||
output[i] = byte;
|
||||
input <<= 2;
|
||||
}
|
||||
|
||||
u8x8_cad_SendData(u8x8, 4, output);
|
||||
ptr += 1;
|
||||
c -= 1;
|
||||
}
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7586s_erc240160_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7586s_erc240160_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7586s_erc240160_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7586s_erc240160_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if (arg_int == 0)
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7586s_sleep_off);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7586s_sleep_on);
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x0C0);
|
||||
u8x8_cad_SendArg(u8x8, arg_int);
|
||||
u8x8_cad_SendArg(u8x8, 1);
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
254
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7586s_s028hn118a.c
Normal file
254
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7586s_s028hn118a.c
Normal file
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
u8x8_d_st7586s_s028hn118a.c
|
||||
|
||||
Display: 384x136 pixel
|
||||
ST7586s: 384 x 160 x 2
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2018, olikraus@gmail.com
|
||||
|
||||
All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g2.h"
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_st7586s_sleep_on[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x010), /* set power save mode */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7586s_sleep_off[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x011), //Sleep out
|
||||
U8X8_DLY(50), /* delay 50 ms */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7586s_s028hn118a_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x036), /* Scan Direction Setting */
|
||||
U8X8_A(0x000), /* COM0 -> COM159 SEG0 -> SEG384 */
|
||||
U8X8_C(0x037), /* Start line 0 */
|
||||
U8X8_A(0x000),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7586s_s028hn118a_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x036), /* Scan Direction Setting */
|
||||
U8X8_A(0x0C8), /* COM159 -> COM0 SEG384 -> SEG0 */
|
||||
U8X8_C(0x037), /* Start line 24 */
|
||||
U8X8_A(0x018),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static uint8_t u8x8_d_st7586s_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) {
|
||||
uint8_t c;
|
||||
uint8_t *ptr;
|
||||
uint8_t i, byte;
|
||||
uint32_t input;
|
||||
uint8_t output[8];
|
||||
switch (msg) {
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8); // OK Start transfer
|
||||
u8x8_cad_SendCmd(u8x8, 0x02B); /* Row Address Setting */
|
||||
u8x8_cad_SendArg(u8x8, 0x000);
|
||||
u8x8_cad_SendArg(u8x8, 0x008 * ((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
u8x8_cad_SendArg(u8x8, 0x000);
|
||||
u8x8_cad_SendArg(u8x8, u8x8->display_info->pixel_height - 1); /* should this be u8x8->display_info->pixel_height - 1 */
|
||||
u8x8_cad_SendCmd(u8x8, 0x02C); /* cmd write display data to ram */
|
||||
c = ((u8x8_tile_t *) arg_ptr)->cnt; //
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *) arg_ptr)->tile_ptr; //
|
||||
|
||||
// The ST7586S has an unusual 3 pixels per byte format so here we read in 3 bytes (24 pixels) and
|
||||
// pack that into 8 bytes of 3 pixels each
|
||||
while (c > 0) {
|
||||
input = (((uint32_t)ptr[0] << 16) | ((uint32_t)ptr[1] << 8) | (uint32_t)ptr[2]);
|
||||
for (i=0; i<8; i++)
|
||||
{
|
||||
byte = 0;
|
||||
if (input & 0x800000) // if bit 23
|
||||
byte = byte | 0xC0; //set pixel 1
|
||||
if (input & 0x400000) // if bit 22
|
||||
byte = byte | 0x18; //set pixel 2
|
||||
if (input & 0x200000) // if bit 22
|
||||
byte = byte | 0x3; //set pixel 3
|
||||
output[i] = byte;
|
||||
input <<= 3;
|
||||
}
|
||||
u8x8_cad_SendData(u8x8, 8, output);
|
||||
ptr += 3;
|
||||
c -= 3;
|
||||
}
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if (arg_int == 0)
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7586s_sleep_off);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7586s_sleep_on);
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x0C0);
|
||||
u8x8_cad_SendArg(u8x8, arg_int);
|
||||
u8x8_cad_SendArg(u8x8, 0);
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const uint8_t u8x8_d_st7586s_s028hn118a_init_seq[] = {
|
||||
U8X8_START_TRANSFER(),/* enable chip */
|
||||
U8X8_END_TRANSFER(),/* disable chip */
|
||||
// U8G_ESC_RST(15), /* hardware reset */
|
||||
U8X8_DLY(60), /* Delay 60 ms */
|
||||
U8X8_START_TRANSFER(),/* enable chip */
|
||||
|
||||
U8X8_C(0x001), // Soft reset
|
||||
U8X8_DLY(60), // Delay 120 ms
|
||||
|
||||
U8X8_C(0x011), // Sleep Out
|
||||
U8X8_C(0x028), // Display OFF
|
||||
U8X8_DLY(25), // Delay 50 ms
|
||||
|
||||
U8X8_CAA(0x0C0,0x0E5,0x00),// Vop = F0h in trace a bit too dark
|
||||
|
||||
U8X8_CA(0x0C3,0x004), // BIAS = 1/10 0x04 in trace
|
||||
|
||||
U8X8_CA(0x0C4,0x005), // Booster = x6 0x05 in trace
|
||||
|
||||
U8X8_CA(0x0D0,0x01D), // Enable Analog Circuit
|
||||
|
||||
U8X8_CA(0x0B3,0x000), // Set FOSC divider
|
||||
|
||||
U8X8_CA(0x0B5,0x08B), // N-Line = 0
|
||||
|
||||
U8X8_C(0x039), // 0x39 Monochrome mode. 0x38 - gray Mode
|
||||
|
||||
U8X8_C(0x03A), // Enable DDRAM Interface
|
||||
U8X8_A(0x002), // monochrome and 4-level
|
||||
|
||||
U8X8_C(0x036), // Scan Direction Setting
|
||||
U8X8_A(0x000), // COM0 -> COM159 SEG0 -> SEG384
|
||||
|
||||
U8X8_C(0x0B0), // Duty Setting (num rows - 1)
|
||||
U8X8_A(0x087), // should be 0x87 but caused flicker 0x9F
|
||||
|
||||
U8X8_C(0x020), // Display inversion off
|
||||
|
||||
U8X8_C(0x02A), // Column Address Setting
|
||||
U8X8_A(0x000), // COL0 -> COL127
|
||||
U8X8_A(0x000), //
|
||||
U8X8_A(0x000), //
|
||||
U8X8_A(0x07f), // 128*3=384 pixels
|
||||
|
||||
U8X8_C(0x02B), // Row Address Setting
|
||||
U8X8_A(0x000), // ROW0 -> ROW135
|
||||
U8X8_A(0x000), //
|
||||
U8X8_A(0x000), //
|
||||
U8X8_A(0x087), // 136 pixels
|
||||
|
||||
U8X8_C(0x0F1), // Frame rate monochrome
|
||||
U8X8_A(0x00C), // The factory firmware set this to 49.0 Hz 0x07
|
||||
U8X8_A(0x00C), // This caused a shimmer under 50Hz LED lights
|
||||
U8X8_A(0x00C), // 69.0 Hz (0x0C) fixes this and should avoid the
|
||||
U8X8_A(0x00C), // issue in the US too
|
||||
|
||||
U8X8_C(0x029), // Display ON
|
||||
U8X8_END_TRANSFER(),/* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const u8x8_display_info_t u8x8_st7586s_s028hn118a_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 5,
|
||||
/* pre_chip_disable_wait_ns = */ 5,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 20,
|
||||
/* sck_pulse_width_ns = */ 100, /* datasheet ST7586S */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* ST7586+Atmega128RFA1 works with 8MHz */
|
||||
/* spi_mode = */ 3, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 20, /* datasheet suggests min 20 */
|
||||
/* write_pulse_width_ns = */ 40,
|
||||
/* tile_width = */ 48,
|
||||
/* tile_height = */ 17,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 384,
|
||||
/* pixel_height = */ 136
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* st7586s_s028hn118a driver. This is the display in the SMART Response XE. This requires 16 bit mode.
|
||||
******************************************************************************/
|
||||
uint8_t u8x8_d_st7586s_s028hn118a(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) {
|
||||
if (u8x8_d_st7586s_common(u8x8, msg, arg_int, arg_ptr) != 0)
|
||||
return 1;
|
||||
|
||||
switch (msg) {
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7586s_s028hn118a_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7586s_s028hn118a_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7586s_s028hn118a_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7586s_s028hn118a_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
243
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7586s_ymc240160.c
Normal file
243
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7586s_ymc240160.c
Normal file
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
u8x8_d_st7586s_ymc240160.c
|
||||
|
||||
Display: 240x160 pixel
|
||||
ST7586s: 384 x 160 x 2
|
||||
|
||||
takeover from https://github.com/olikraus/u8g2/issues/1183
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2020, olikraus@gmail.com
|
||||
|
||||
All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g2.h"
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_st7586s_sleep_on[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x010), /* set power save mode */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7586s_sleep_off[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x011), //Sleep out
|
||||
U8X8_DLY(50), /* delay 50 ms */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7586s_ymc240160_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x036), /* Scan Direction Setting */
|
||||
U8X8_A(0x080), /* COM159 -> COM0 SEG383 -> SEG0 */
|
||||
U8X8_C(0x037), /* Start line 0 */
|
||||
U8X8_A(0x000),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7586s_ymc240160_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x036), /* Scan Direction Setting */
|
||||
U8X8_A(0x000), /* COM0 -> COM159 SEG0 -> SEG383 */
|
||||
U8X8_C(0x037), /* Start line 0 */
|
||||
U8X8_A(0x000),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7586s_ymc240160_init_seq[] = {
|
||||
U8X8_START_TRANSFER(),/* enable chip */
|
||||
U8X8_END_TRANSFER(),/* disable chip */
|
||||
// U8G_ESC_RST(1), /* hardware reset */
|
||||
U8X8_DLY(60), /* Delay 60 ms */
|
||||
U8X8_START_TRANSFER(),/* enable chip */
|
||||
|
||||
U8X8_C(0x001), // Soft reset
|
||||
U8X8_DLY(60), // Delay 120 ms
|
||||
|
||||
U8X8_C(0x011), // Sleep Out
|
||||
U8X8_C(0x028), // Display OFF
|
||||
U8X8_DLY(25), // Delay 50 ms
|
||||
|
||||
U8X8_CAA(0x0C0,0x036,0x01),// Vop = 136h data sheet suggested 0x0145 but this caused streaks
|
||||
|
||||
U8X8_CA(0x0C3,0x000), // BIAS = 1/14
|
||||
|
||||
U8X8_CA(0x0C4,0x007), // Booster = x8
|
||||
|
||||
U8X8_CA(0x0D0,0x01D), // Enable Analog Circuit
|
||||
|
||||
U8X8_CA(0x0B3,0x000), // Set FOSC divider
|
||||
|
||||
U8X8_CA(0x0B5,0x000), // N-Line = 0
|
||||
|
||||
U8X8_C(0x039), // 0x39 Monochrome mode. 0x38 - gray Mode
|
||||
|
||||
U8X8_C(0x03A), // Enable DDRAM Interface
|
||||
U8X8_A(0x002), // monochrome and 4-level
|
||||
|
||||
U8X8_C(0x036), // Scan Direction Setting
|
||||
U8X8_A(0x080), // COM:C159->C0 SEG: SEG383->SEG0
|
||||
|
||||
U8X8_C(0x0B1), // First output COM
|
||||
U8X8_A(0x000), //
|
||||
|
||||
U8X8_C(0x0B0), // Duty Setting (num rows - 1)
|
||||
U8X8_A(0x09F),
|
||||
|
||||
U8X8_C(0x020), // Display inversion off
|
||||
|
||||
U8X8_C(0x02A), // Column Address Setting
|
||||
U8X8_A(0x000), // COL0 -> COL127
|
||||
U8X8_A(0x000), //
|
||||
U8X8_A(0x000), //
|
||||
U8X8_A(0x04F), // 80*3=240 pixels
|
||||
|
||||
U8X8_C(0x02B), // Row Address Setting
|
||||
U8X8_A(0x000), // ROW0 -> ROW159
|
||||
U8X8_A(0x000), //
|
||||
U8X8_A(0x000), //
|
||||
U8X8_A(0x09F), // 160 pixels
|
||||
|
||||
U8X8_C(0x029), // Display ON
|
||||
U8X8_END_TRANSFER(),/* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const u8x8_display_info_t u8x8_st7586s_ymc240160_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 5,
|
||||
/* pre_chip_disable_wait_ns = */ 5,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 20,
|
||||
/* sck_pulse_width_ns = */ 100, /* datasheet ST7586S */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* ST7586+Atmega128RFA1 works with 8MHz */
|
||||
/* spi_mode = */ 3, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 20, /* datasheet suggests min 20 */
|
||||
/* write_pulse_width_ns = */ 40,
|
||||
/* tile_width = */ 30,
|
||||
/* tile_height = */ 20,
|
||||
/* default_x_offset = */ 0, /* abused as flag to know if we are flipped */
|
||||
/* flipmode_x_offset = */ 1, /* as pixel order different for normal/flipped */
|
||||
/* pixel_width = */ 240,
|
||||
/* pixel_height = */ 160
|
||||
};
|
||||
|
||||
/* takeover from https://github.com/olikraus/u8g2/issues/1183 */
|
||||
uint8_t u8x8_d_st7586s_ymc240160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t c;
|
||||
uint8_t *ptr;
|
||||
uint8_t i, byte;
|
||||
uint32_t input;
|
||||
uint8_t output[8];
|
||||
// uint8_t output[4];
|
||||
switch (msg) {
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8); // OK Start transfer
|
||||
u8x8_cad_SendCmd(u8x8, 0x02B); /* Row Address Setting */
|
||||
u8x8_cad_SendArg(u8x8, 0x000);
|
||||
u8x8_cad_SendArg(u8x8, 0x008 * ((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
u8x8_cad_SendArg(u8x8, 0x000);
|
||||
// u8x8_cad_SendArg(u8x8, 0x09F); // should set end row based on display dimensions
|
||||
u8x8_cad_SendArg(u8x8, u8x8->display_info->pixel_height - 1); /* should this be u8x8->display_info->pixel_height - 1 */
|
||||
u8x8_cad_SendCmd(u8x8, 0x02C); /* cmd write display data to ram */
|
||||
c = ((u8x8_tile_t *) arg_ptr)->cnt; //
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *) arg_ptr)->tile_ptr; //
|
||||
|
||||
while (c > 0)
|
||||
{
|
||||
input = (((uint32_t)ptr[0] << 16) | ((uint32_t)ptr[1] << 8) | (uint32_t)ptr[2]);
|
||||
for (i=0; i<8; i++)
|
||||
{
|
||||
byte = 0;
|
||||
if (input & 0x800000) // if bit 23
|
||||
byte = byte | 0xC0; //set pixel 1
|
||||
if (input & 0x400000) // if bit 22
|
||||
byte = byte | 0x18; //set pixel 2
|
||||
if (input & 0x200000) // if bit 22
|
||||
byte = byte | 0x3; //set pixel 3
|
||||
output[i] = byte;
|
||||
input <<= 3;
|
||||
}
|
||||
u8x8_cad_SendData(u8x8, 8, output);
|
||||
ptr += 3;
|
||||
c -= 3;
|
||||
}
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7586s_ymc240160_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7586s_ymc240160_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7586s_ymc240160_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7586s_ymc240160_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if (arg_int == 0)
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7586s_sleep_off);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7586s_sleep_on);
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x0C0);
|
||||
u8x8_cad_SendArg(u8x8, arg_int);
|
||||
u8x8_cad_SendArg(u8x8, 1);
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
256
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7588.c
Normal file
256
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7588.c
Normal file
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
|
||||
u8x8_d_st7588.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2017, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
ST7588
|
||||
- has 4 different I2C addresses
|
||||
- I2C protocol is identical to SSD13xx
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
/* function set, bit 2: power down, bit 3: MY, bit 4: MX, bit 5: must be 1 */
|
||||
#define FS (0x020)
|
||||
|
||||
/* not a real power down for the ST7588... just a display off */
|
||||
static const uint8_t u8x8_d_st7588_128x64_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C( FS | 0x00 ), /* select 00 commands */
|
||||
//U8X8_C( 0x08 ), /* display off */
|
||||
U8X8_C( 0x0c ), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7588_128x64_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C( FS | 0x00 ), /* select 00 commands */
|
||||
U8X8_C( 0x08 ), /* display off */
|
||||
//U8X8_C( 0x0c ), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
static uint8_t u8x8_d_st7588_128x64_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7588_128x64_display_info);
|
||||
break;
|
||||
*/
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7588_128x64_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7588_128x64_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7588_128x64_powersave1_seq);
|
||||
|
||||
/* restore orientation */
|
||||
if ( u8x8->x_offset == 0 )
|
||||
u8x8_cad_SendCmd(u8x8, FS ); /* select 00 commands */
|
||||
else
|
||||
u8x8_cad_SendCmd(u8x8, FS ^ 0x018 ); /* select 00 commands */
|
||||
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, FS );
|
||||
u8x8_cad_SendArg(u8x8, 4 | (arg_int>>7) );
|
||||
u8x8_cad_SendCmd(u8x8, FS | 1);
|
||||
u8x8_cad_SendArg(u8x8, 0x080 | arg_int );
|
||||
|
||||
/* restore orientation */
|
||||
if ( u8x8->x_offset == 0 )
|
||||
u8x8_cad_SendCmd(u8x8, FS ); /* select 00 commands */
|
||||
else
|
||||
u8x8_cad_SendCmd(u8x8, FS ^ 0x018 ); /* select 00 commands */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
|
||||
x += u8x8->x_offset;
|
||||
|
||||
if ( u8x8->x_offset == 0 )
|
||||
u8x8_cad_SendCmd(u8x8, FS ); /* select 00 commands */
|
||||
else
|
||||
u8x8_cad_SendCmd(u8x8, FS ^ 0x018 ); /* select 00 commands */
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x040 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0e0 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0f0 | (x>>4) );
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*=============================================*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_st7588_128x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 150,
|
||||
/* pre_chip_disable_wait_ns = */ 30,
|
||||
/* reset_pulse_width_ms = */ 5,
|
||||
/* post_reset_wait_ms = */ 5, /**/
|
||||
/* sda_setup_time_ns = */ 60, /* */
|
||||
/* sck_pulse_width_ns = */ 60, /* */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4, /* 400KHz */
|
||||
/* data_setup_time_ns = */ 80,
|
||||
/* write_pulse_width_ns = */ 50,
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0, /* must be 0, because this is checked also for normal mode */
|
||||
/* flipmode_x_offset = */ 4,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_st7588_128x64_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C( FS | 0x03 ), /* select 11 commands */
|
||||
U8X8_C( 0x03 ), /* software reset */
|
||||
|
||||
U8X8_C( FS | 0x00 ), /* select 00 commands */
|
||||
U8X8_C( 0x08 ), /* display off */
|
||||
//U8X8_C( 0x0c ), /* display on */
|
||||
|
||||
U8X8_C( FS | 0x01 ), /* select 01 commands */
|
||||
U8X8_C( 0x08 ), /* display confguration */
|
||||
U8X8_C( 0x12 ), /* bias 1/9 */
|
||||
U8X8_C( 0x8f ), /* Vop, lower 7 bits */
|
||||
|
||||
U8X8_C( FS | 0x00 ), /* select 00 commands */
|
||||
U8X8_C( 0x05), /* Bit 0 contains high/low range for Vop */
|
||||
|
||||
|
||||
U8X8_C( FS | 0x03 ), /* select 11 commands */
|
||||
U8X8_C( 0x0b), /* Frame Rate: 73 Hz */
|
||||
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_st7588_jlx12864_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C( FS ), /* normal mode */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7588_jlx12864_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C( FS ^ 0x018 ), /* normal mode */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_st7588_jlx12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( u8x8_d_st7588_128x64_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
||||
return 1;
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_SetI2CAddress(u8x8, 0x07e); /* the JLX12864 has 0x07e as a default address for I2C */
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7588_128x64_display_info);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
||||
{
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7588_128x64_init_seq);
|
||||
return 1;
|
||||
}
|
||||
else if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE )
|
||||
{
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7588_jlx12864_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7588_jlx12864_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
272
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7920.c
Normal file
272
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_st7920.c
Normal file
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
|
||||
u8x8_d_st7920.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
The ST7920 controller does not support hardware graphics flip.
|
||||
Contrast adjustment is done by an external resistor --> no support for contrast adjustment
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_st7920_init_seq[] = {
|
||||
|
||||
U8X8_DLY(100),
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(10),
|
||||
|
||||
U8X8_C(0x038), /* 8 Bit interface (DL=1), basic instruction set (RE=0) */
|
||||
U8X8_C(0x008), /* display on, cursor & blink off; 0x08: all off */
|
||||
U8X8_C(0x006), /* Entry mode: Cursor move to right ,DDRAM address counter (AC) plus 1, no shift */
|
||||
U8X8_C(0x002), /* disable scroll, enable CGRAM adress */
|
||||
U8X8_C(0x001), /* clear RAM, needs 1.6 ms */
|
||||
U8X8_DLY(4), /* delay 2ms */
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7920_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x038), /* 8 Bit interface (DL=1), basic instruction set (RE=0) */
|
||||
U8X8_C(0x00c), /* display on, cursor & blink off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_st7920_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x038), /* 8 Bit interface (DL=1), basic instruction set (RE=0) */
|
||||
U8X8_C(0x008), /* display off */
|
||||
U8X8_C(0x034), /* 8 Bit interface (DL=1), extended instruction set (RE=1) */
|
||||
U8X8_C(0x001), /* Standby mode */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_st7920_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, y, c, i;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* U8X8_MSG_DISPLAY_SETUP_MEMORY is handled by the calling function */
|
||||
/*
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7920_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7920_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_st7920_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
y*=8;
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x /= 2; /* not sure whether this is a clever idea, problem is, the ST7920 can address only every second tile */
|
||||
|
||||
if ( y >= 32 ) /* this is the adjustment for 128x64 displays */
|
||||
{
|
||||
y-=32;
|
||||
x+=8;
|
||||
}
|
||||
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
|
||||
/*
|
||||
Tile structure is reused here for the ST7920, however u8x8 is not supported
|
||||
tile_ptr points to data which has cnt*8 bytes (same as SSD1306 tiles)
|
||||
Buffer is expected to have 8 lines of code fitting to the ST7920 internal memory
|
||||
"cnt" includes the number of horizontal bytes. width is equal to cnt*8
|
||||
Also important: Width must be a multiple of 16 (ST7920 requirement), so cnt must be even.
|
||||
|
||||
TODO: Consider arg_int, however arg_int is not used by u8g2
|
||||
*/
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
|
||||
/* The following byte is sent to allow the ST7920 to sync up with the data */
|
||||
/* it solves some issues with garbage data */
|
||||
u8x8_cad_SendCmd(u8x8, 0x03e ); /* enable extended mode */
|
||||
u8x8_cad_SendCmd(u8x8, 0x03e ); /* enable extended mode, issue 487 */
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
//u8x8_cad_SendCmd(u8x8, 0x03e ); /* enable extended mode */
|
||||
u8x8_cad_SendCmd(u8x8, 0x080 | (y+i) ); /* y pos */
|
||||
u8x8_cad_SendCmd(u8x8, 0x080 | x ); /* set x pos */
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
||||
|
||||
//u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes, send one line of data */
|
||||
ptr += c;
|
||||
//u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */
|
||||
}
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const u8x8_display_info_t u8x8_st7920_192x32_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 1,
|
||||
/* chip_disable_level = */ 0,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 5,
|
||||
/* pre_chip_disable_wait_ns = */ 5,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 20,
|
||||
/* sck_pulse_width_ns = */ 140, /* datasheet ST7920 */
|
||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 3, /* old: sck_takeover_edge, new: active high (bit 1), rising edge (bit 0), 18 Aug 16: changed from 1 to 3 which works for 101 */
|
||||
/* Arduino mode 3: aktive low clock, but use rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30,
|
||||
/* write_pulse_width_ns = */ 40,
|
||||
/* tile_width = */ 24,
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 192,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
static const u8x8_display_info_t u8x8_st7920_128x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 1,
|
||||
/* chip_disable_level = */ 0,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 5,
|
||||
/* pre_chip_disable_wait_ns = */ 5,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 20,
|
||||
/* sck_pulse_width_ns = */ 140, /* datasheet ST7920 */
|
||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* ST7920+Due work with 1MHz but not with 2MHz, ST7920+Uno works with 2MHz */
|
||||
/* spi_mode = */ 3, /* active high, rising edge, 18 Aug 16: changed from 1 to 3 which works for 101 */
|
||||
/* in theory mode 3 should be correct */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30,
|
||||
/* write_pulse_width_ns = */ 40,
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_st7920_192x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7920_192x32_display_info);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_st7920_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8x8_d_st7920_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7920_128x64_display_info);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_st7920_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* https://github.com/olikraus/u8g2/issues/1593 */
|
||||
|
||||
static const u8x8_display_info_t u8x8_st7920_256x32_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 1,
|
||||
/* chip_disable_level = */ 0,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 5,
|
||||
/* pre_chip_disable_wait_ns = */ 5,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 20,
|
||||
/* sck_pulse_width_ns = */ 140, /* datasheet ST7920 */
|
||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* ST7920+Due work with 1MHz but not with 2MHz, ST7920+Uno works with 2MHz */
|
||||
/* spi_mode = */ 3, /* active high, rising edge, 18 Aug 16: changed from 1 to 3 which works for 101 */
|
||||
/* in theory mode 3 should be correct */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30,
|
||||
/* write_pulse_width_ns = */ 40,
|
||||
/* tile_width = */ 32,
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 256,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_st7920_256x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7920_256x32_display_info);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_st7920_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
564
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_t6963.c
Normal file
564
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_t6963.c
Normal file
@@ -0,0 +1,564 @@
|
||||
/*
|
||||
|
||||
u8x8_d_t6963.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
The t6963 controller does not support hardware graphics flip.
|
||||
Contrast adjustment is done by an external resistor --> no support for contrast adjustment
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_t6963_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x098), /* mode register: Display Mode, Graphics on, Text off, Cursor off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_t6963_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x090), /* All Off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_t6963_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t c, i;
|
||||
uint16_t y;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* U8X8_MSG_DISPLAY_SETUP_MEMORY is handled by the calling function */
|
||||
/*
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
y*=8;
|
||||
y*= u8x8->display_info->tile_width;
|
||||
/* x = ((u8x8_tile_t *)arg_ptr)->x_pos; x is ignored... no u8x8 support */
|
||||
//u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
//u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */
|
||||
/*
|
||||
Tile structure is reused here for the t6963, however u8x8 is not supported
|
||||
tile_ptr points to data which has cnt*8 bytes (same as SSD1306 tiles)
|
||||
Buffer is expected to have 8 lines of code fitting to the t6963 internal memory
|
||||
"cnt" includes the number of horizontal bytes. width is equal to cnt*8
|
||||
|
||||
TODO: Consider arg_int, however arg_int is not used by u8g2
|
||||
*/
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
u8x8_cad_SendArg(u8x8, y&255);
|
||||
u8x8_cad_SendArg(u8x8, y>>8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x024 ); /* set adr */
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 ); /* auto write start */
|
||||
|
||||
|
||||
//c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes, send one line of data */
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b2 ); /* auto write reset */
|
||||
ptr += u8x8->display_info->tile_width;
|
||||
y += u8x8->display_info->tile_width;
|
||||
}
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
//u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*=============================================*/
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_t6963_240x128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 110, /* T6963 Datasheet p30 */
|
||||
/* pre_chip_disable_wait_ns = */ 100, /* T6963 Datasheet p30 */
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 20,
|
||||
/* sck_pulse_width_ns = */ 140,
|
||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0,
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 80,
|
||||
/* write_pulse_width_ns = */ 80,
|
||||
/* tile_width = */ 30,
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 240,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
/* 240x128 */
|
||||
static const uint8_t u8x8_d_t6963_240x128_init_seq[] = {
|
||||
U8X8_DLY(100),
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(100),
|
||||
|
||||
U8X8_AAC(0x00,0x00,0x021), /* low, high, set cursor pos */
|
||||
U8X8_AAC(0x00,0x00,0x022), /* low, high, set offset */
|
||||
U8X8_AAC(0x00,0x00,0x040), /* low, high, set text home */
|
||||
U8X8_AAC(240/8,0x00,0x041), /* low, high, set text columns */
|
||||
U8X8_AAC(0x00,0x00,0x042), /* low, high, graphics home */
|
||||
U8X8_AAC(240/8,0x00,0x043), /* low, high, graphics columns */
|
||||
U8X8_DLY(2), /* delay 2ms */
|
||||
// mode set
|
||||
// 0x080: Internal CG, OR Mode
|
||||
// 0x081: Internal CG, EXOR Mode
|
||||
// 0x083: Internal CG, AND Mode
|
||||
// 0x088: External CG, OR Mode
|
||||
// 0x089: External CG, EXOR Mode
|
||||
// 0x08B: External CG, AND Mode
|
||||
U8X8_C(0x080), /* mode register: OR Mode, Internal Character Mode */
|
||||
// display mode
|
||||
// 0x090: Display off
|
||||
// 0x094: Graphic off, text on, cursor off, blink off
|
||||
// 0x096: Graphic off, text on, cursor on, blink off
|
||||
// 0x097: Graphic off, text on, cursor on, blink on
|
||||
// 0x098: Graphic on, text off, cursor off, blink off
|
||||
// 0x09a: Graphic on, text off, cursor on, blink off
|
||||
// ...
|
||||
// 0x09c: Graphic on, text on, cursor off, blink off
|
||||
// 0x09f: Graphic on, text on, cursor on, blink on
|
||||
U8X8_C(0x090), /* All Off */
|
||||
U8X8_AAC(0x00,0x00,0x024), /* low, high, set adr pointer */
|
||||
|
||||
U8X8_DLY(100),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_DLY(100),
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_t6963_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_t6963_240x128_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_240x128_init_seq);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_t6963_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*=============================================*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_t6963_240x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 110, /* T6963 Datasheet p30 */
|
||||
/* pre_chip_disable_wait_ns = */ 100, /* T6963 Datasheet p30 */
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 20,
|
||||
/* sck_pulse_width_ns = */ 140,
|
||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0,
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 80,
|
||||
/* write_pulse_width_ns = */ 80,
|
||||
/* tile_width = */ 30,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 240,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
|
||||
/* 240x64 */
|
||||
static const uint8_t u8x8_d_t6963_240x64_init_seq[] = {
|
||||
U8X8_DLY(100),
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(100),
|
||||
|
||||
U8X8_AAC(0x00,0x00,0x021), /* low, high, set cursor pos */
|
||||
U8X8_AAC(0x00,0x00,0x022), /* low, high, set offset */
|
||||
U8X8_AAC(0x00,0x00,0x040), /* low, high, set text home */
|
||||
U8X8_AAC(240/8,0x00,0x041), /* low, high, set text columns */
|
||||
U8X8_AAC(0x00,0x00,0x042), /* low, high, graphics home */
|
||||
U8X8_AAC(240/8,0x00,0x043), /* low, high, graphics columns */
|
||||
U8X8_DLY(2), /* delay 2ms */
|
||||
// mode set
|
||||
// 0x080: Internal CG, OR Mode
|
||||
// 0x081: Internal CG, EXOR Mode
|
||||
// 0x083: Internal CG, AND Mode
|
||||
// 0x088: External CG, OR Mode
|
||||
// 0x089: External CG, EXOR Mode
|
||||
// 0x08B: External CG, AND Mode
|
||||
U8X8_C(0x080), /* mode register: OR Mode, Internal Character Mode */
|
||||
// display mode
|
||||
// 0x090: Display off
|
||||
// 0x094: Graphic off, text on, cursor off, blink off
|
||||
// 0x096: Graphic off, text on, cursor on, blink off
|
||||
// 0x097: Graphic off, text on, cursor on, blink on
|
||||
// 0x098: Graphic on, text off, cursor off, blink off
|
||||
// 0x09a: Graphic on, text off, cursor on, blink off
|
||||
// ...
|
||||
// 0x09c: Graphic on, text on, cursor off, blink off
|
||||
// 0x09f: Graphic on, text on, cursor on, blink on
|
||||
U8X8_C(0x090), /* All Off */
|
||||
U8X8_AAC(0x00,0x00,0x024), /* low, high, set adr pointer */
|
||||
|
||||
U8X8_DLY(100),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_DLY(100),
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_t6963_240x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_t6963_240x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_240x64_init_seq);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_t6963_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*=============================================*/
|
||||
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_t6963_256x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 110, /* T6963 Datasheet p30 */
|
||||
/* pre_chip_disable_wait_ns = */ 100, /* T6963 Datasheet p30 */
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 20,
|
||||
/* sck_pulse_width_ns = */ 140,
|
||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0,
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 80,
|
||||
/* write_pulse_width_ns = */ 80,
|
||||
/* tile_width = */ 32,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 256,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
/* 256x64 */
|
||||
static const uint8_t u8x8_d_t6963_256x64_init_seq[] = {
|
||||
U8X8_DLY(100),
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(100),
|
||||
|
||||
U8X8_AAC(0x00,0x00,0x021), /* low, high, set cursor pos */
|
||||
U8X8_AAC(0x00,0x00,0x022), /* low, high, set offset */
|
||||
U8X8_AAC(0x00,0x00,0x040), /* low, high, set text home */
|
||||
U8X8_AAC(256/8,0x00,0x041), /* low, high, set text columns */
|
||||
U8X8_AAC(0x00,0x00,0x042), /* low, high, graphics home */
|
||||
U8X8_AAC(256/8,0x00,0x043), /* low, high, graphics columns */
|
||||
U8X8_DLY(2), /* delay 2ms */
|
||||
// mode set
|
||||
// 0x080: Internal CG, OR Mode
|
||||
// 0x081: Internal CG, EXOR Mode
|
||||
// 0x083: Internal CG, AND Mode
|
||||
// 0x088: External CG, OR Mode
|
||||
// 0x089: External CG, EXOR Mode
|
||||
// 0x08B: External CG, AND Mode
|
||||
U8X8_C(0x080), /* mode register: OR Mode, Internal Character Mode */
|
||||
// display mode
|
||||
// 0x090: Display off
|
||||
// 0x094: Graphic off, text on, cursor off, blink off
|
||||
// 0x096: Graphic off, text on, cursor on, blink off
|
||||
// 0x097: Graphic off, text on, cursor on, blink on
|
||||
// 0x098: Graphic on, text off, cursor off, blink off
|
||||
// 0x09a: Graphic on, text off, cursor on, blink off
|
||||
// ...
|
||||
// 0x09c: Graphic on, text on, cursor off, blink off
|
||||
// 0x09f: Graphic on, text on, cursor on, blink on
|
||||
U8X8_C(0x090), /* All Off */
|
||||
U8X8_AAC(0x00,0x00,0x024), /* low, high, set adr pointer */
|
||||
|
||||
U8X8_DLY(100),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_DLY(100),
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_t6963_256x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_t6963_256x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_256x64_init_seq);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_t6963_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*=============================================*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_t6963_128x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 1,
|
||||
/* chip_disable_level = */ 0,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 10, /* T6963 Datasheet p30 */
|
||||
/* pre_chip_disable_wait_ns = */ 100, /* T6963 Datasheet p30 */
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 20,
|
||||
/* sck_pulse_width_ns = */ 140,
|
||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0,
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 80,
|
||||
/* write_pulse_width_ns = */ 80,
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
/* 128x64 */
|
||||
static const uint8_t u8x8_d_t6963_128x64_init_seq[] = {
|
||||
U8X8_DLY(100),
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(100),
|
||||
|
||||
U8X8_AAC(0x00,0x00,0x021), /* low, high, set cursor pos */
|
||||
U8X8_AAC(0x00,0x00,0x022), /* low, high, set offset */
|
||||
U8X8_AAC(0x00,0x00,0x040), /* low, high, set text home */
|
||||
U8X8_AAC(128/8,0x00,0x041), /* low, high, set text columns */
|
||||
U8X8_AAC(0x00,0x00,0x042), /* low, high, graphics home */
|
||||
U8X8_AAC(128/8,0x00,0x043), /* low, high, graphics columns */
|
||||
U8X8_DLY(2), /* delay 2ms */
|
||||
// mode set
|
||||
// 0x080: Internal CG, OR Mode
|
||||
// 0x081: Internal CG, EXOR Mode
|
||||
// 0x083: Internal CG, AND Mode
|
||||
// 0x088: External CG, OR Mode
|
||||
// 0x089: External CG, EXOR Mode
|
||||
// 0x08B: External CG, AND Mode
|
||||
U8X8_C(0x080), /* mode register: OR Mode, Internal Character Mode */
|
||||
// display mode
|
||||
// 0x090: Display off
|
||||
// 0x094: Graphic off, text on, cursor off, blink off
|
||||
// 0x096: Graphic off, text on, cursor on, blink off
|
||||
// 0x097: Graphic off, text on, cursor on, blink on
|
||||
// 0x098: Graphic on, text off, cursor off, blink off
|
||||
// 0x09a: Graphic on, text off, cursor on, blink off
|
||||
// ...
|
||||
// 0x09c: Graphic on, text on, cursor off, blink off
|
||||
// 0x09f: Graphic on, text on, cursor on, blink on
|
||||
U8X8_C(0x090), /* All Off */
|
||||
U8X8_AAC(0x00,0x00,0x024), /* low, high, set adr pointer */
|
||||
|
||||
U8X8_DLY(100),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_DLY(100),
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_t6963_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_t6963_128x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_128x64_init_seq);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_t6963_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*=============================================*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_t6963_160x80_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 10, /* T6963 Datasheet p30 */
|
||||
/* pre_chip_disable_wait_ns = */ 100, /* T6963 Datasheet p30 */
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 20,
|
||||
/* sck_pulse_width_ns = */ 140,
|
||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0,
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 80,
|
||||
/* write_pulse_width_ns = */ 80,
|
||||
/* tile_width = */ 20,
|
||||
/* tile_hight = */ 10,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 160,
|
||||
/* pixel_height = */ 80
|
||||
};
|
||||
|
||||
/* 128x64 */
|
||||
static const uint8_t u8x8_d_t6963_160x80_init_seq[] = {
|
||||
U8X8_DLY(100),
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(100),
|
||||
|
||||
U8X8_AAC(0x00,0x00,0x021), /* low, high, set cursor pos */
|
||||
U8X8_AAC(0x00,0x00,0x022), /* low, high, set offset */
|
||||
U8X8_AAC(0x00,0x00,0x040), /* low, high, set text home */
|
||||
U8X8_AAC(160/8,0x00,0x041), /* low, high, set text columns */
|
||||
U8X8_AAC(0x00,0x00,0x042), /* low, high, graphics home */
|
||||
U8X8_AAC(160/8,0x00,0x043), /* low, high, graphics columns */
|
||||
U8X8_DLY(2), /* delay 2ms */
|
||||
// mode set
|
||||
// 0x080: Internal CG, OR Mode
|
||||
// 0x081: Internal CG, EXOR Mode
|
||||
// 0x083: Internal CG, AND Mode
|
||||
// 0x088: External CG, OR Mode
|
||||
// 0x089: External CG, EXOR Mode
|
||||
// 0x08B: External CG, AND Mode
|
||||
U8X8_C(0x080), /* mode register: OR Mode, Internal Character Mode */
|
||||
// display mode
|
||||
// 0x090: Display off
|
||||
// 0x094: Graphic off, text on, cursor off, blink off
|
||||
// 0x096: Graphic off, text on, cursor on, blink off
|
||||
// 0x097: Graphic off, text on, cursor on, blink on
|
||||
// 0x098: Graphic on, text off, cursor off, blink off
|
||||
// 0x09a: Graphic on, text off, cursor on, blink off
|
||||
// ...
|
||||
// 0x09c: Graphic on, text on, cursor off, blink off
|
||||
// 0x09f: Graphic on, text on, cursor on, blink on
|
||||
U8X8_C(0x090), /* All Off */
|
||||
U8X8_AAC(0x00,0x00,0x024), /* low, high, set adr pointer */
|
||||
|
||||
U8X8_DLY(100),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_DLY(100),
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_t6963_160x80(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_t6963_160x80_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_160x80_init_seq);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_t6963_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* alternative version for the 128x64 t6963 display: use the 160x80 init sequence */
|
||||
uint8_t u8x8_d_t6963_128x64_alt(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_t6963_128x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_160x80_init_seq);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_t6963_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
304
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1601.c
Normal file
304
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1601.c
Normal file
@@ -0,0 +1,304 @@
|
||||
/*
|
||||
|
||||
u8x8_d_uc1601.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2017, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This is for the uc1601s controller
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_uc1601_128x32_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1601_128x32_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1601_128x32_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0c4), /* bit 1: MX, bit 2: MY */
|
||||
U8X8_C(0x060), /* set display start line to 32 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1601_128x32_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0c2), /* bit 1: MX, bit 2: MY */
|
||||
U8X8_C(0x040), /* set display start line to 0 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1601_128x32_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 1, /* uc1601 datasheet, page 46 */
|
||||
/* pre_chip_disable_wait_ns = */ 5, /* uc1601 datasheet, page 46 */
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 12, /* uc1601 datasheet, page 44 */
|
||||
/* sck_pulse_width_ns = */ 15, /* uc1601 datasheet, page 44 */
|
||||
/* sck_clock_hz = */ 2000000UL, /* */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 1,
|
||||
/* data_setup_time_ns = */ 60, /* uc1601 datasheet, page 43 */
|
||||
/* write_pulse_width_ns = */ 80, /* uc1601 datasheet, page 43 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 4,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1601_128x32_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0e2), /* soft reset */
|
||||
U8X8_C(0x0eb), /* LCD Bias: 0xe8: 6, 0xe9: 7, 0xea: 8, 0xeb: 9 */
|
||||
//U8X8_C(0x023), /* 0x020...0x023 only for UC1601, not for UC1601s */
|
||||
|
||||
|
||||
//U8X8_C(0x02e), /* LCD Load + Internal Charge Pump (default: 0x2e) */
|
||||
U8X8_C(0x024), /* Temperature Compenstation, default: 0x24 */
|
||||
U8X8_C(0x089), /* RAM address ctrl, default: 0x89 */
|
||||
U8X8_C(0x0c4), /* RAM mapping ctrl */
|
||||
U8X8_C(0x0a0), /* Frame Rate, 0x0a0 or 0x0a1 */
|
||||
U8X8_CA(0x081, 0x0df), /* set contrast */
|
||||
U8X8_C(0x02e), /* LCD Load + Internal Charge Pump (default: 0x2e) */
|
||||
U8X8_C(0x060), /* set display start line to 32 */
|
||||
|
||||
U8X8_C(0x0a6), /* normal display */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_uc1601_128x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1601_128x32_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1601_128x32_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1601_128x32_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1601_128x32_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1601_128x32_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1601_128x32_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* uc1601 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* issue https://github.com/olikraus/u8g2/issues/1501 */
|
||||
|
||||
static const uint8_t u8x8_d_uc1601_128x64_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0e2), /* soft reset */
|
||||
U8X8_C(0x0eb), /* LCD Bias: 0xe8: 6, 0xe9: 7, 0xea: 8, 0xeb: 9 */
|
||||
//U8X8_C(0x023), /* 0x020...0x023 only for UC1601, not for UC1601s */
|
||||
|
||||
|
||||
//U8X8_C(0x02e), /* LCD Load + Internal Charge Pump (default: 0x2e) */
|
||||
U8X8_C(0x024), /* Temperature Compenstation, default: 0x24 */
|
||||
U8X8_C(0x089), /* RAM address ctrl, default: 0x89 */
|
||||
U8X8_C(0x0c4), /* RAM mapping ctrl */
|
||||
U8X8_C(0x0a0), /* Frame Rate, 0x0a0 or 0x0a1 */
|
||||
U8X8_CA(0x081, 0x0df), /* set contrast */
|
||||
U8X8_C(0x02e), /* LCD Load + Internal Charge Pump (default: 0x2e) */
|
||||
U8X8_C(0x040), /* set display start: See Issue 1501 */
|
||||
|
||||
U8X8_C(0x0a6), /* normal display */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1601_128x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 1, /* uc1601 datasheet, page 46 */
|
||||
/* pre_chip_disable_wait_ns = */ 5, /* uc1601 datasheet, page 46 */
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 12, /* uc1601 datasheet, page 44 */
|
||||
/* sck_pulse_width_ns = */ 15, /* uc1601 datasheet, page 44 */
|
||||
/* sck_clock_hz = */ 2000000UL, /* */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 1,
|
||||
/* data_setup_time_ns = */ 60, /* uc1601 datasheet, page 43 */
|
||||
/* write_pulse_width_ns = */ 80, /* uc1601 datasheet, page 43 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 2,
|
||||
/* flipmode_x_offset = */ 4, /* IS THIS CORRECT? */
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_uc1601_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1601_128x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1601_128x64_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1601_128x32_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1601_128x32_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1601_128x32_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1601_128x32_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* uc1601 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
240
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1604.c
Normal file
240
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1604.c
Normal file
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
|
||||
u8x8_d_uc1604.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_uc1604_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(20),
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_DLY(20), /* during setup, it seems that the startup is more reliable when sending this cmd twice */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_DLY(50), /* startup takes some time */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1604_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off, enter sleep mode */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1604_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0c4), /* LCD Mapping */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1604_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0c2), /* LCD Mapping */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_uc1604_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
|
||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
||||
y += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (y&15));
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
/* handled in the calling procedure
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1604_128x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1604_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1604_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1604_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1604_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* uc1604 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*================================================*/
|
||||
/* JLX19264 */
|
||||
|
||||
/*
|
||||
timings from uc1608
|
||||
|
||||
UC1604 has two chip select inputs (CS0 and CS1).
|
||||
CS0 is low active, CS1 is high active. It will depend on the display
|
||||
module whether the display has a is low or high active chip select.
|
||||
|
||||
*/
|
||||
static const u8x8_display_info_t u8x8_uc1604_192x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0, /* JLX19264G uses CS0, which is low active CS*/
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 20,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 10,
|
||||
/* sda_setup_time_ns = */ 30,
|
||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30,
|
||||
/* write_pulse_width_ns = */ 35,
|
||||
/* tile_width = */ 24, /* width of 24*8=192 pixel */
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0, /* reused as y page offset */
|
||||
/* flipmode_x_offset = */ 0, /* reused as y page offset */
|
||||
/* pixel_width = */ 192,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1604_jlx19264_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0e2), /* soft reset */
|
||||
U8X8_DLY(200),
|
||||
U8X8_DLY(200),
|
||||
|
||||
U8X8_C(0x02f), /* power on, Bit 2 PC2=1 (internal charge pump), Bits 0/1: cap of panel */
|
||||
U8X8_DLY(200),
|
||||
U8X8_DLY(200),
|
||||
|
||||
U8X8_CA(0x081, 0x052), /* set contrast, JLX19264G suggestion: 0x045 */
|
||||
U8X8_C(0x0eb), /* LCD bias Bits 0/1: 00=6 01=7, 10=8, 11=9 */
|
||||
|
||||
|
||||
//U8X8_C(0x023), /* Bit 0/1: Temp compenstation, Bit 2: Multiplex Rate 0=96, 1=128 */
|
||||
//U8X8_C(0x027), /* Bit 0/1: Temp compenstation, Bit 2: Multiplex Rate 0=96, 1=128 */
|
||||
|
||||
U8X8_C(0x0c4), /* Map control, Bit 2: MY=1, Bit 1: MX=0 */
|
||||
U8X8_C(0x0a0), /* 0xa0: 76Hz FPS, controller default: 0x0a1: 95Hz FPS */
|
||||
|
||||
|
||||
U8X8_C(0x040), /* set scroll line to 0 */
|
||||
U8X8_C(0x089), /* RAM access control (controller default: 0x089)*/
|
||||
|
||||
|
||||
U8X8_C(0x000), /* column low nibble */
|
||||
U8X8_C(0x010), /* column high nibble */
|
||||
U8X8_C(0x0b0), /* page adr */
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_uc1604_jlx19264(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call common procedure first and handle messages there */
|
||||
if ( u8x8_d_uc1604_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1604_192x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1604_jlx19264_init_seq);
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
512
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1608.c
Normal file
512
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1608.c
Normal file
@@ -0,0 +1,512 @@
|
||||
/*
|
||||
|
||||
u8x8_d_uc1608.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_uc1608_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1608_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off, enter sleep mode */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1608_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0c8), /* LCD Mapping */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1608_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0c4), /* LCD Mapping */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_uc1608_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
|
||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
||||
y += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (y&15));
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
/* handled in the calling procedure
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1608_128x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1608_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1608_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1608_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1608_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* uc1608 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*================================================*/
|
||||
/* ERC24064-1 */
|
||||
|
||||
/*
|
||||
The UC1608 has only one high active chip select input.
|
||||
UC1604, UC1610 and UC1611 have two chip select inputs.
|
||||
*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1608_240x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 1, /* uc1608 has high active CS */
|
||||
/* chip_disable_level = */ 0,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 10, /* uc1608 datasheet, page 39, actually 0 */
|
||||
/* pre_chip_disable_wait_ns = */ 20, /* uc1608 datasheet, page 39 */
|
||||
/* reset_pulse_width_ms = */ 1, /* uc1608 datasheet, page 42 */
|
||||
/* post_reset_wait_ms = */ 10,
|
||||
/* sda_setup_time_ns = */ 30, /* uc1608 datasheet, page 41 */
|
||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30, /* uc1608 datasheet, page 39 */
|
||||
/* write_pulse_width_ns = */ 35, /* uc1608 datasheet, page 39 */
|
||||
/* tile_width = */ 30, /* width of 30*8=240 pixel */
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0, /* reused as y page offset */
|
||||
/* flipmode_x_offset = */ 4, /* reused as y page offset */
|
||||
/* pixel_width = */ 240,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1608_erc24064_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0e2), /* soft reset */
|
||||
U8X8_DLY(200),
|
||||
|
||||
U8X8_C(0x023), /* Bit 0/1: Temp compenstation, Bit 2: Multiplex Rate 0=96, 1=128 */
|
||||
//U8X8_C(0x027), /* Bit 0/1: Temp compenstation, Bit 2: Multiplex Rate 0=96, 1=128 */
|
||||
|
||||
U8X8_C(0x0c8), /* Map control, Bit 3: MY=1, Bit 2: MX=0, Bit 0: MSF =0 */
|
||||
U8X8_C(0x0e8), /* LCD bias Bits 0/1: 00=10.7 01=10.3, 10=12.0, 11=12.7 */
|
||||
|
||||
U8X8_C(0x02f), /* power on, Bit 2 PC2=1 (internal charge pump), Bits 0/1: cap of panel */
|
||||
U8X8_DLY(50),
|
||||
|
||||
U8X8_C(0x040), /* set display start line to 0 */
|
||||
U8X8_C(0x090), /* no fixed lines */
|
||||
U8X8_C(0x089), /* RAM access control */
|
||||
|
||||
U8X8_CA(0x081, 0x014), /* set contrast, ERC24064-1 default: 0x040 */
|
||||
|
||||
U8X8_C(0x000), /* column low nibble */
|
||||
U8X8_C(0x010), /* column high nibble */
|
||||
U8X8_C(0x0b0), /* page adr */
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_uc1608_erc24064(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call common procedure first and handle messages there */
|
||||
if ( u8x8_d_uc1608_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1608_240x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1608_erc24064_init_seq);
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*================================================*/
|
||||
/* experimental implementation for the uc1608 240x128, not referenced in codebuild */
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1608_240x128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 1, /* uc1608 has high active CS */
|
||||
/* chip_disable_level = */ 0,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 10, /* uc1608 datasheet, page 39, actually 0 */
|
||||
/* pre_chip_disable_wait_ns = */ 20, /* uc1608 datasheet, page 39 */
|
||||
/* reset_pulse_width_ms = */ 1, /* uc1608 datasheet, page 42 */
|
||||
/* post_reset_wait_ms = */ 10,
|
||||
/* sda_setup_time_ns = */ 30, /* uc1608 datasheet, page 41 */
|
||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30, /* uc1608 datasheet, page 39 */
|
||||
/* write_pulse_width_ns = */ 35, /* uc1608 datasheet, page 39 */
|
||||
/* tile_width = */ 30, /* width of 30*8=240 pixel */
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 0, /* reused as y page offset */
|
||||
/* flipmode_x_offset = */ 0, /* reused as y page offset */
|
||||
/* pixel_width = */ 240,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1608_240x128_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0e2), /* soft reset */
|
||||
U8X8_DLY(200),
|
||||
|
||||
//U8X8_C(0x023), /* Bit 0/1: Temp compenstation, Bit 2: Multiplex Rate 0=96, 1=128 */
|
||||
U8X8_C(0x026), /* Bit 0/1: Temp compenstation, Bit 2: Multiplex Rate 0=96, 1=128 */
|
||||
|
||||
U8X8_C(0x0c8), /* Map control, Bit 3: MY=1, Bit 2: MX=0, Bit 0: MSF =0 */
|
||||
U8X8_C(0x0ea), /* LCD bias Bits 0/1: 00=10.7 01=10.3, 10=12.0, 11=12.7 */
|
||||
/* maybe 0x0eb??? */
|
||||
|
||||
U8X8_C(0x02f), /* power on, Bit 2 PC2=1 (internal charge pump), Bits 0/1: cap of panel */
|
||||
U8X8_DLY(50),
|
||||
|
||||
U8X8_C(0x040), /* set display start line to 0 */
|
||||
U8X8_C(0x090), /* no fixed lines */
|
||||
U8X8_C(0x089), /* RAM access control */
|
||||
|
||||
U8X8_CA(0x081, 0x072), /* set contrast */
|
||||
|
||||
U8X8_C(0x000), /* column low nibble */
|
||||
U8X8_C(0x010), /* column high nibble */
|
||||
U8X8_C(0x0b0), /* page adr */
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_uc1608_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call common procedure first and handle messages there */
|
||||
if ( u8x8_d_uc1608_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1608_240x128_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1608_240x128_init_seq);
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*================================================*/
|
||||
/* experimental implementation for the uc1608 erc240x120 */
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1608_erc240120_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 1, /* uc1608 has high active CS */
|
||||
/* chip_disable_level = */ 0,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 10, /* uc1608 datasheet, page 39, actually 0 */
|
||||
/* pre_chip_disable_wait_ns = */ 20, /* uc1608 datasheet, page 39 */
|
||||
/* reset_pulse_width_ms = */ 1, /* uc1608 datasheet, page 42 */
|
||||
/* post_reset_wait_ms = */ 10,
|
||||
/* sda_setup_time_ns = */ 30, /* uc1608 datasheet, page 41 */
|
||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30, /* uc1608 datasheet, page 39 */
|
||||
/* write_pulse_width_ns = */ 35, /* uc1608 datasheet, page 39 */
|
||||
/* tile_width = */ 30, /* width of 30*8=240 pixel */
|
||||
/* tile_hight = */ 15,
|
||||
/* default_x_offset = */ 1, /* reused as y page offset */
|
||||
/* flipmode_x_offset = */ 0, /* reused as y page offset */
|
||||
/* pixel_width = */ 240,
|
||||
/* pixel_height = */ 120
|
||||
};
|
||||
|
||||
/* http://www.buydisplay.com/download/democode/ERC240120-1_DemoCode.txt */
|
||||
static const uint8_t u8x8_d_uc1608_erc240120_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0e2), /* soft reset */
|
||||
U8X8_DLY(200),
|
||||
|
||||
//U8X8_C(0x023), /* Bit 0/1: Temp compenstation, Bit 2: Multiplex Rate 0=96, 1=128 */
|
||||
U8X8_C(0x026), /* Bit 0/1: Temp compenstation, Bit 2: Multiplex Rate 0=96, 1=128 */
|
||||
|
||||
U8X8_C(0x0c8), /* Map control, Bit 3: MY=1, Bit 2: MX=0, Bit 0: MSF =0 */
|
||||
U8X8_C(0x0ea), /* LCD bias Bits 0/1: 00=10.7 01=10.3, 10=12.0, 11=12.7 */
|
||||
/* according to DemoCode.txt */
|
||||
|
||||
U8X8_C(0x02f), /* power on, Bit 2 PC2=1 (internal charge pump), Bits 0/1: cap of panel */
|
||||
U8X8_DLY(50),
|
||||
|
||||
U8X8_C(0x040), /* set display start line to 0 */
|
||||
U8X8_C(0x090), /* no fixed lines */
|
||||
U8X8_C(0x089), /* RAM access control */
|
||||
|
||||
//U8X8_CA(0x081, 46), /* set contrast, 46 according to DemoCode.txt */
|
||||
U8X8_CA(0x081, 80), /* */
|
||||
|
||||
U8X8_C(0x000), /* column low nibble */
|
||||
U8X8_C(0x010), /* column high nibble */
|
||||
U8X8_C(0x0b0), /* page adr */
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_uc1608_erc240120(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call common procedure first and handle messages there */
|
||||
if ( u8x8_d_uc1608_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1608_erc240120_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1608_erc240120_init_seq);
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*================================================*/
|
||||
/* DEM 240064, issue 1164 */
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1608_dem240064_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 1, /* uc1608 has high active CS */
|
||||
/* chip_disable_level = */ 0,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 10, /* uc1608 datasheet, page 39, actually 0 */
|
||||
/* pre_chip_disable_wait_ns = */ 20, /* uc1608 datasheet, page 39 */
|
||||
/* reset_pulse_width_ms = */ 1, /* uc1608 datasheet, page 42 */
|
||||
/* post_reset_wait_ms = */ 10,
|
||||
/* sda_setup_time_ns = */ 30, /* uc1608 datasheet, page 41 */
|
||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30, /* uc1608 datasheet, page 39 */
|
||||
/* write_pulse_width_ns = */ 35, /* uc1608 datasheet, page 39 */
|
||||
/* tile_width = */ 30, /* width of 30*8=240 pixel */
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 1, /* reused as y page offset */
|
||||
/* flipmode_x_offset = */ 0, /* reused as y page offset */
|
||||
/* pixel_width = */ 240,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
/* http://www.buydisplay.com/download/democode/ERC240120-1_DemoCode.txt */
|
||||
static const uint8_t u8x8_d_uc1608_dem240064_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0e2), /* soft reset */
|
||||
U8X8_DLY(200),
|
||||
|
||||
//U8X8_C(0x023), /* Bit 0/1: Temp compenstation, Bit 2: Multiplex Rate 0=96, 1=128 */
|
||||
U8X8_C(0x026), /* Bit 0/1: Temp compenstation, Bit 2: Multiplex Rate 0=96, 1=128 */
|
||||
|
||||
U8X8_C(0x0c8), /* Map control, Bit 3: MY=1, Bit 2: MX=0, Bit 0: MSF =0 */
|
||||
U8X8_C(0x0ea), /* LCD bias Bits 0/1: 00=10.7 01=10.3, 10=12.0, 11=12.7 */
|
||||
/* according to DemoCode.txt */
|
||||
|
||||
U8X8_C(0x02f), /* power on, Bit 2 PC2=1 (internal charge pump), Bits 0/1: cap of panel */
|
||||
U8X8_DLY(50),
|
||||
|
||||
U8X8_C(0x07f), /* set display start line*/
|
||||
U8X8_C(0x094), /* fixed lines */
|
||||
U8X8_C(0x089), /* RAM access control */
|
||||
|
||||
U8X8_CA(0x081, 160), /* issue 1164 */
|
||||
|
||||
U8X8_C(0x000), /* column low nibble */
|
||||
U8X8_C(0x010), /* column high nibble */
|
||||
U8X8_C(0x0b0), /* page adr */
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1608_dem240064_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0c8), /* LCD Mapping */
|
||||
U8X8_C(0x07f), /* set display start line*/
|
||||
U8X8_C(0x094), /* fixed lines */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1608_dem240064_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0c4), /* LCD Mapping */
|
||||
U8X8_C(0x040), /* set display start line*/
|
||||
U8X8_C(0x090), /* fixed lines */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_uc1608_dem240064(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
||||
/* checking for the flip mode cmd first */
|
||||
if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE )
|
||||
{
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1608_dem240064_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1608_dem240064_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/* call the common procedure, this now leads to the effect, that the flip code is executed again */
|
||||
/* maybe we should paste the common code here to avoid this */
|
||||
|
||||
|
||||
if ( u8x8_d_uc1608_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1608_dem240064_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1608_dem240064_init_seq);
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
208
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1609.c
Normal file
208
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1609.c
Normal file
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
|
||||
u8x8_d_uc1609.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2021, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
https://github.com/olikraus/u8g2/issues/1565
|
||||
|
||||
cad001
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_uc1609_19264_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_CA(0x0f1, 63), /* set COM end (display height-1) */
|
||||
U8X8_C(0x0c0), /* SEG & COM normal */
|
||||
U8X8_C(0x040), /* set scroll line to zero */
|
||||
U8X8_C(0x02e), /* chare pump */
|
||||
U8X8_C(0x0eb), /* set bias 1/2 */
|
||||
U8X8_CA(0x081, 0x08f), /* set contrast */
|
||||
|
||||
/*
|
||||
AC0: 0: stop at boundary, 1: increment by one
|
||||
AC1: 0: first column then page, 1: first page, then column increment
|
||||
AC2: 0: increment page adr, 1: decrement page adr.
|
||||
*/
|
||||
U8X8_C(0x088), /* set auto increment, low bits are AC2 AC1 AC0 */
|
||||
U8X8_C(0x0a1), /* frame rate 95Hz */
|
||||
|
||||
|
||||
/*
|
||||
LC0: 0
|
||||
MX: Mirror X
|
||||
MY: Mirror Y
|
||||
*/
|
||||
U8X8_C(0x0c4), /* low bits are MY, MX, LC0 */
|
||||
|
||||
U8X8_C(0x0a6), /* set normal pixel mode (not inverse) */
|
||||
U8X8_C(0x0a4), /* set normal pixel mode (not all on) */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1609_19264_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on, UC1609 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1609_19264_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off, UC1609 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1609_19264_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
/*
|
||||
LC0: 0
|
||||
MX: Mirror X
|
||||
MY: Mirror Y
|
||||
*/
|
||||
U8X8_C(0x0c4), /* low bits are MY, MX, LC0 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1609_19264_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
/*
|
||||
LC0: 0
|
||||
MX: Mirror X
|
||||
MY: Mirror Y
|
||||
*/
|
||||
U8X8_C(0x0c2), /* low bits are MY, MX, LC0 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1609_19264_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 15,
|
||||
/* pre_chip_disable_wait_ns = */ 15,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 30,
|
||||
/* sck_pulse_width_ns = */ 63, /* half of cycle time (125ns cycle time according to datasheet) --> 8MHz clock */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30,
|
||||
/* write_pulse_width_ns = */ 40,
|
||||
/* tile_width = */ 24,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 192,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_uc1609_slg19264(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c, page;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1609_19264_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1609_19264_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1609_19264_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1609_19264_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1609_19264_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1609_19264_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* uc1610 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
page = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | page);
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr);
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
297
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1610.c
Normal file
297
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1610.c
Normal file
@@ -0,0 +1,297 @@
|
||||
/*
|
||||
|
||||
u8x8_d_uc1610.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
cad001
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_uc1610_dogxl160_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_CA(0x0f1, 0x067), /* set COM end (display height-1) */
|
||||
U8X8_C(0x0c0), /* SEG & COM normal */
|
||||
U8X8_C(0x040), /* set scroll line lsb to zero */
|
||||
U8X8_C(0x050), /* set scroll line msb to zero */
|
||||
U8X8_C(0x02b), /* set panelloading */
|
||||
U8X8_C(0x0eb), /* set bias 1/2 */
|
||||
U8X8_CA(0x081, 0x05f), /* set contrast */
|
||||
|
||||
/*
|
||||
AC0: 0: stop at boundary, 1: increment by one
|
||||
AC1: 0: first column then page, 1: first page, then column increment
|
||||
AC2: 0: increment page adr, 1: decrement page adr.
|
||||
*/
|
||||
U8X8_C(0x08b), /* set auto increment, low bits are AC2 AC1 AC0 */
|
||||
|
||||
/*
|
||||
LC0: 0
|
||||
MX: Mirror X
|
||||
MY: Mirror Y
|
||||
*/
|
||||
U8X8_C(0x0c0), /* low bits are MY, MX, LC0 */
|
||||
|
||||
U8X8_C(0x0f8), // window mode off
|
||||
U8X8_C(0x010), // col high
|
||||
U8X8_C(0x000), // col low
|
||||
U8X8_C(0x0b0), // page
|
||||
|
||||
U8X8_C(0x0a6), /* set normal pixel mode (not inverse) */
|
||||
U8X8_C(0x0a4), /* set normal pixel mode (not all on) */
|
||||
|
||||
/* test code
|
||||
U8X8_C(0x0af), // display on
|
||||
U8X8_C(0x0f8), // window mode off
|
||||
U8X8_CA(0x0f4, 0), // set window
|
||||
U8X8_CA(0x0f5, 0),
|
||||
U8X8_CA(0x0f6, 4),
|
||||
U8X8_CA(0x0f7, 1),
|
||||
U8X8_C(0x0f9), // window mode on
|
||||
U8X8_D1(0x03),
|
||||
U8X8_D1(0x0c0),
|
||||
U8X8_D1(0x0ff),
|
||||
U8X8_D1(0x0ff),
|
||||
U8X8_D1(0x0ff),
|
||||
U8X8_D1(0x0ff),
|
||||
U8X8_D1(0x0ff),
|
||||
U8X8_D1(0x0ff),
|
||||
*/
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1610_dogxl160_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on, UC1610 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1610_dogxl160_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off, UC1610 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1610_dogxl160_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
/*
|
||||
LC0: 0
|
||||
MX: Mirror X
|
||||
MY: Mirror Y
|
||||
*/
|
||||
U8X8_C(0x0c0), /* low bits are MY, MX, LC0 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1610_dogxl160_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
/*
|
||||
LC0: 0
|
||||
MX: Mirror X
|
||||
MY: Mirror Y
|
||||
*/
|
||||
U8X8_C(0x0c6), /* low bits are MY, MX, LC0 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
UC1610 has two chip select inputs (CS0 and CS1).
|
||||
CS0 is low active, CS1 is high active. It will depend on the display
|
||||
module whether the display has a is low or high active chip select.
|
||||
*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1610_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 15,
|
||||
/* pre_chip_disable_wait_ns = */ 15,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 30,
|
||||
/* sck_pulse_width_ns = */ 63, /* half of cycle time (125ns cycle time according to datasheet) --> 8MHz clock */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30,
|
||||
/* write_pulse_width_ns = */ 40,
|
||||
/* tile_width = */ 20,
|
||||
/* tile_hight = */ 13, /* height of 13*8=104 pixel */
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 160,
|
||||
/* pixel_height = */ 104
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
RAM Organization:
|
||||
D0 Pix0
|
||||
D1
|
||||
D2 Pix1
|
||||
D3
|
||||
D4 Pix2
|
||||
D5
|
||||
D6 Pix3
|
||||
D7
|
||||
D0 Pix4
|
||||
D1
|
||||
D2 Pix5
|
||||
D3
|
||||
D4 Pix6
|
||||
D5
|
||||
D6 Pix7
|
||||
D7
|
||||
|
||||
|
||||
*/
|
||||
static uint8_t *u8x8_convert_tile_for_uc1610(uint8_t *t)
|
||||
{
|
||||
uint8_t i;
|
||||
uint16_t r;
|
||||
static uint8_t buf[16];
|
||||
uint8_t *pbuf = buf;
|
||||
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
r = u8x8_upscale_byte(*t++);
|
||||
*pbuf++ = r & 255;
|
||||
r >>= 8;
|
||||
*pbuf++ = r;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
uint8_t u8x8_d_uc1610_ea_dogxl160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c, page;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1610_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1610_dogxl160_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1610_dogxl160_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1610_dogxl160_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1610_dogxl160_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1610_dogxl160_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* uc1610 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
page = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
||||
page *= 2;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x0f8 ); /* window disable */
|
||||
|
||||
//u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
//u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
//u8x8_cad_SendCmd(u8x8, 0x0b0 | page);
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x0f4 ); /* window start column */
|
||||
u8x8_cad_SendArg(u8x8, x);
|
||||
u8x8_cad_SendCmd(u8x8, 0x0f5 ); /* window start page */
|
||||
u8x8_cad_SendArg(u8x8, page);
|
||||
u8x8_cad_SendCmd(u8x8, 0x0f6 ); /* window end column */
|
||||
u8x8_cad_SendArg(u8x8, 159); /* end of display */
|
||||
u8x8_cad_SendCmd(u8x8, 0x0f7 ); /* window end page */
|
||||
u8x8_cad_SendArg(u8x8, page+1);
|
||||
u8x8_cad_SendCmd(u8x8, 0x0f9 ); /* window enable */
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 16, u8x8_convert_tile_for_uc1610(ptr));
|
||||
ptr += 8;
|
||||
x += 8;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
767
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1611.c
Normal file
767
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1611.c
Normal file
@@ -0,0 +1,767 @@
|
||||
/*
|
||||
|
||||
u8x8_d_uc1611.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
6 Nov 2016: Not yet finished
|
||||
|
||||
There are two controller:
|
||||
UC1611s 160x256
|
||||
UC1611 160x240
|
||||
|
||||
Differences:
|
||||
UC1611 0xa8 cmd: enables 80 display rows
|
||||
UC1611s 0xa8 cmd: controlls graylevels
|
||||
|
||||
UC1611 0xc0 cmd: single byte command for LCD mapping control
|
||||
UC1611s 0xc0 cmd: double byte command for LCD mapping control
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_uc1611s_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a9), /* display on, UC1611s */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1611s_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a8), /* display off, enter sleep mode, UC1611s */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1611s_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0c0, 0x004), /* LCD Mapping */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1611s_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0c0, 0x002), /* LCD Mapping */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_uc1611_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
|
||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
||||
u8x8_cad_SendCmd(u8x8, 0x060 | (y&15));
|
||||
u8x8_cad_SendCmd(u8x8, 0x070 | (y>>4));
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
/* handled in the calling procedure
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1611_128x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq);
|
||||
break;
|
||||
*/
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* uc1611 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*================================================*/
|
||||
/* EA DOGM240 */
|
||||
|
||||
|
||||
/*
|
||||
UC1611 has two chip select inputs (CS0 and CS1).
|
||||
CS0 is low active, CS1 is high active. It will depend on the display
|
||||
module whether the display has a is low or high active chip select.
|
||||
*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1611_240x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 10, /* uc1611 datasheet, page 60, actually 0 */
|
||||
/* pre_chip_disable_wait_ns = */ 10, /* uc1611 datasheet, page 60, actually 0 */
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 10, /* uc1611 datasheet, page 67 */
|
||||
/* sda_setup_time_ns = */ 10, /* uc1611 datasheet, page 64, actually 0 */
|
||||
/* sck_pulse_width_ns = */ 60, /* half of cycle time */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30, /* uc1611 datasheet, page 60 */
|
||||
/* write_pulse_width_ns = */ 80, /* uc1611 datasheet, page 60 */
|
||||
/* tile_width = */ 30, /* width of 30*8=240 pixel */
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 240,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1611_ea_dogm240_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x02f), /* internal pump control */
|
||||
U8X8_CA(0x0f1, 63), /* set COM end */
|
||||
U8X8_CA(0x0f2, 0x000), /* display line start */
|
||||
U8X8_CA(0x0f3, 63), /* display line end */
|
||||
U8X8_C(0x0a3), /* line rate */
|
||||
U8X8_CA(0x081, 0x0a4), /* set contrast, EA default: 0x0b7 */
|
||||
|
||||
//U8X8_C(0x0a9), /* display enable */
|
||||
|
||||
U8X8_C(0x0d1), /* display pattern */
|
||||
U8X8_C(0x089), /* auto increment */
|
||||
U8X8_CA(0x0c0, 0x004), /* LCD Mapping */
|
||||
U8X8_C(0x000), /* column low nibble */
|
||||
U8X8_C(0x010), /* column high nibble */
|
||||
U8X8_C(0x060), /* page adr low */
|
||||
U8X8_C(0x070), /* page adr high */
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
/* UC1611s 240x64 display */
|
||||
uint8_t u8x8_d_uc1611_ea_dogm240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call common procedure first and handle messages there */
|
||||
if ( u8x8_d_uc1611_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1611_240x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611_ea_dogm240_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*================================================*/
|
||||
/* EA DOGXL240 */
|
||||
|
||||
static const uint8_t u8x8_d_uc1611_ea_dogxl240_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x02f), /* internal pump control */
|
||||
U8X8_CA(0x0f1, 0x07f), /* set COM end */
|
||||
U8X8_CA(0x0f2, 0x000), /* display line start */
|
||||
U8X8_CA(0x0f3, 127), /* display line end */
|
||||
U8X8_C(0x0a3), /* line rate */
|
||||
U8X8_CA(0x081, 0x08f), /* set contrast */
|
||||
|
||||
//U8X8_C(0x0a9), /* display enable */
|
||||
|
||||
U8X8_C(0x0d1), /* display pattern */
|
||||
U8X8_C(0x089), /* auto increment */
|
||||
U8X8_CA(0x0c0, 0x004), /* LCD Mapping */
|
||||
U8X8_C(0x000), /* column low nibble */
|
||||
U8X8_C(0x010), /* column high nibble */
|
||||
U8X8_C(0x060), /* page adr low */
|
||||
U8X8_C(0x070), /* page adr high */
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1611_240x128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 10, /* uc1611 datasheet, page 60, actually 0 */
|
||||
/* pre_chip_disable_wait_ns = */ 10, /* uc1611 datasheet, page 60, actually 0 */
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 10, /* uc1611 datasheet, page 67 */
|
||||
/* sda_setup_time_ns = */ 10, /* uc1611 datasheet, page 64, actually 0 */
|
||||
/* sck_pulse_width_ns = */ 60, /* half of cycle time */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30, /* uc1611 datasheet, page 60 */
|
||||
/* write_pulse_width_ns = */ 80, /* uc1611 datasheet, page 60 */
|
||||
/* tile_width = */ 30, /* width of 30*8=240 pixel */
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 240,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
/* UC1611s 240x128 display */
|
||||
uint8_t u8x8_d_uc1611_ea_dogxl240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call common procedure first and handle messages there */
|
||||
if ( u8x8_d_uc1611_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1611_240x128_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611_ea_dogxl240_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*================================================*/
|
||||
/* EMERGING DISPLAY, EW50850FLWP 240x160 */
|
||||
/* active high CS (CS1), UC1611 display */
|
||||
|
||||
static const uint8_t u8x8_d_uc1611_ew50850_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x02f), /* internal pump control */
|
||||
U8X8_CA(0x0f1, 159), /* set COM end */
|
||||
U8X8_CA(0x0f2, 0), /* display line start */
|
||||
U8X8_CA(0x0f3, 159), /* display line end */
|
||||
U8X8_C(0x0a3), /* line rate */
|
||||
U8X8_CA(0x081, 75), /* set contrast */
|
||||
|
||||
//U8X8_C(0x0a9), /* display enable */
|
||||
|
||||
U8X8_C(0x0d2), /* gray level mode: 16 gray shades */
|
||||
U8X8_C(0x089), /* auto increment */
|
||||
U8X8_C(0x0c0), /* LCD Mapping Bit 0: MSF, Bit 1: MX, Bit 2: MY */
|
||||
U8X8_C(0x000), /* column low nibble */
|
||||
U8X8_C(0x010), /* column high nibble */
|
||||
U8X8_C(0x060), /* page adr low */
|
||||
U8X8_C(0x070), /* page adr high */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1611_ew50850_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 1, /* active high */
|
||||
/* chip_disable_level = */ 0,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 10, /* uc1611 datasheet, page 60, actually 0 */
|
||||
/* pre_chip_disable_wait_ns = */ 10, /* uc1611 datasheet, page 60, actually 0 */
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 10, /* uc1611 datasheet, page 67 */
|
||||
/* sda_setup_time_ns = */ 10, /* uc1611 datasheet, page 64, actually 0 */
|
||||
/* sck_pulse_width_ns = */ 60, /* half of cycle time */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30, /* uc1611 datasheet, page 60 */
|
||||
/* write_pulse_width_ns = */ 80, /* uc1611 datasheet, page 60 */
|
||||
/* tile_width = */ 30, /* width of 30*8=240 pixel */
|
||||
/* tile_hight = */ 20, /* height: 160 pixel */
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 240,
|
||||
/* pixel_height = */ 160
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1611_alt_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0c0), /* LCD Mapping Bit 0: MSF, Bit 1: MX, Bit 2: MY */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1611_alt_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0c6), /* LCD Mapping Bit 0: MSF, Bit 1: MX, Bit 2: MY */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1611_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0af), /* display on, UC1611 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1611_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a8), /* display off, enter sleep mode, UC1611 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/* EW50850, 240x160 */
|
||||
uint8_t u8x8_d_uc1611_ew50850(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, y, c, i, v, m0, m1, ai;
|
||||
uint8_t *ptr;
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
||||
y*=4;
|
||||
m0 = 1;
|
||||
m1 = 2;
|
||||
for( i = 0; i < 4; i++ )
|
||||
{
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x060 | (y&15));
|
||||
u8x8_cad_SendCmd(u8x8, 0x070 | (y>>4));
|
||||
|
||||
ai = arg_int;
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
while( c > 0 )
|
||||
{
|
||||
v = 0;
|
||||
if ( *ptr & m0 )
|
||||
v|= 0x0f;
|
||||
if ( *ptr & m1 )
|
||||
v|= 0xf0;
|
||||
u8x8_cad_SendData(u8x8, 1, &v); /* note: SendData can not handle more than 255 bytes */
|
||||
c--;
|
||||
ptr++;
|
||||
}
|
||||
ai--;
|
||||
} while( ai > 0 );
|
||||
|
||||
m0 <<= 2;
|
||||
m1 <<= 2;
|
||||
y++;
|
||||
}
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1611_ew50850_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611_ew50850_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611_alt_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611_alt_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* uc1611 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*================================================*/
|
||||
/* CG160160D, http://www.cloverdisplay.com/pdf/CG160160D.pdf */
|
||||
|
||||
/*
|
||||
UC1611 has two chip select inputs (CS0 and CS1).
|
||||
CS0 is low active, CS1 is high active. It will depend on the display
|
||||
module whether the display has a is low or high active chip select.
|
||||
|
||||
Connect CS1 to 3.3V and CS0 to GPIO
|
||||
*/
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1611_cg160160_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0, /* use CS0 of the UC1611 */
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 10, /* uc1611 datasheet, page 60, actually 0 */
|
||||
/* pre_chip_disable_wait_ns = */ 10, /* uc1611 datasheet, page 60, actually 0 */
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 10, /* uc1611 datasheet, page 67 */
|
||||
/* sda_setup_time_ns = */ 10, /* uc1611 datasheet, page 64, actually 0 */
|
||||
/* sck_pulse_width_ns = */ 60, /* half of cycle time */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30, /* uc1611 datasheet, page 60 */
|
||||
/* write_pulse_width_ns = */ 80, /* uc1611 datasheet, page 60 */
|
||||
/* tile_width = */ 20, /* width of 20*8=160 pixel */
|
||||
/* tile_hight = */ 20,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 160,
|
||||
/* pixel_height = */ 160
|
||||
};
|
||||
|
||||
/*
|
||||
System Reset: E2H --> DONE
|
||||
Set Temp. Compensation: 24H --> DONE
|
||||
Set up LCD format specific parameters MX,MY,etc(double-byte command): C0H,04H --> FLIP0
|
||||
Set line rate: A3H --> DONE
|
||||
Set Pump Control (internal Vlcd): 2FH --> DONE
|
||||
Set Isolation Clock Front (3 bytes command): 82H, 13H, 01H --> DONE
|
||||
Set Isolation Clock Back (3 bytes command): 82H, 14H, 00H --> DONE
|
||||
Set LCD Bias Ratio: EAH
|
||||
LCD Specific Operation Voltage Setting (double-byte command): 81H, 90H --> DONE
|
||||
Set RAM Address Control: 80H --> DOES NOT MAKE SENSE
|
||||
Set Page Addr. MSB: 72H --> DONE
|
||||
Set Page Addr. LSB : 60H --> DONE
|
||||
Set Column Addr. LSB: 00H --> DONE
|
||||
Set Column Addr.MSB: 10H --> DONE
|
||||
Window Program Enable : F8H --> NOT REQURED
|
||||
Window Starting Column (double-byte command): F4H , 00H --> NOT REQURED
|
||||
Window Ending Column (double-byte command): F6H, 9FH --> NOT REQURED
|
||||
Set one bit for one pixel: D1H --> DONE
|
||||
Set Display Enable: A9H
|
||||
*/
|
||||
|
||||
static const uint8_t u8x8_d_uc1611_cg160160_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0e2), /* system reset */
|
||||
U8X8_DLY(2),
|
||||
U8X8_C(0x024), /* Temp. Compensation to 0 = -0.05%/ Grad C */
|
||||
U8X8_C(0x0a3), /* line rate */
|
||||
U8X8_C(0x02f), /* internal pump control */
|
||||
U8X8_CAA(0x082, 0x013, 0x001), /* Isolation front clock, "1" is the default value */
|
||||
U8X8_CAA(0x082, 0x014, 0x000), /* Isolation back clock, "0" is the default value */
|
||||
U8X8_C(0x0ea), /* bias ratio, default: 0x0ea */
|
||||
U8X8_CA(0x081, 0x090), /* set contrast, CG160160: 0x090 */
|
||||
|
||||
//U8X8_CA(0x0f1, 159), /* set COM end */
|
||||
//U8X8_CA(0x0f2, 0), /* display line start */
|
||||
//U8X8_CA(0x0f3, 159), /* display line end */
|
||||
|
||||
//U8X8_C(0x0a9), /* display enable */
|
||||
|
||||
U8X8_C(0x089), /* RAM Address Control: auto increment */
|
||||
U8X8_C(0x0d1), /* display pattern */
|
||||
U8X8_CA(0x0c0, 0x004), /* LCD Mapping */
|
||||
U8X8_C(0x000), /* column low nibble */
|
||||
U8X8_C(0x010), /* column high nibble */
|
||||
U8X8_C(0x060), /* page adr low */
|
||||
U8X8_C(0x070), /* page adr high */
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
/* cg160160 display */
|
||||
uint8_t u8x8_d_uc1611_cg160160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call common procedure first and handle messages there */
|
||||
if ( u8x8_d_uc1611_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1611_cg160160_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611_cg160160_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*================================================*/
|
||||
/* CI064-4073-06 (Intelligent Display Solutions), IDS4073*/
|
||||
/* https://docs.rs-online.com/7e6e/0900766b8156b018.pdf */
|
||||
|
||||
static const uint8_t u8x8_d_uc1611_ids4073_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x02f), /* internal pump control */
|
||||
U8X8_CA(0x0f1, 0x07f), /* set COM end */
|
||||
U8X8_CA(0x0f2, 0x000), /* display line start */
|
||||
U8X8_CA(0x0f3, 127), /* display line end */
|
||||
U8X8_C(0x0a3), /* line rate */
|
||||
U8X8_CA(0x081, 0x08f), /* set contrast */
|
||||
|
||||
//U8X8_C(0x0a9), /* display enable */
|
||||
|
||||
U8X8_C(0x0d1), /* display pattern */
|
||||
U8X8_C(0x089), /* auto increment */
|
||||
U8X8_CA(0x0c0, 0x004), /* LCD Mapping */
|
||||
U8X8_C(0x000), /* column low nibble */
|
||||
U8X8_C(0x010), /* column high nibble */
|
||||
U8X8_C(0x060), /* page adr low */
|
||||
U8X8_C(0x070), /* page adr high */
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1611_256x128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 10, /* uc1611 datasheet, page 60, actually 0 */
|
||||
/* pre_chip_disable_wait_ns = */ 10, /* uc1611 datasheet, page 60, actually 0 */
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 10, /* uc1611 datasheet, page 67 */
|
||||
/* sda_setup_time_ns = */ 10, /* uc1611 datasheet, page 64, actually 0 */
|
||||
/* sck_pulse_width_ns = */ 60, /* half of cycle time */
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30, /* uc1611 datasheet, page 60 */
|
||||
/* write_pulse_width_ns = */ 80, /* uc1611 datasheet, page 60 */
|
||||
/* tile_width = */ 32, /* width of 32*8=256 pixel */
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 256,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
/* UC1611s 256x128 display */
|
||||
uint8_t u8x8_d_uc1611_ids4073(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
|
||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
||||
u8x8_cad_SendCmd(u8x8, 0x060 | (y&15));
|
||||
u8x8_cad_SendCmd(u8x8, 0x070 | (y>>4));
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
/* SendData can not handle more than 255 bytes */
|
||||
if ( c > 31 )
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 248, ptr); /* 31*8=248 */
|
||||
ptr+=248;
|
||||
c -= 31;
|
||||
}
|
||||
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr);
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* uc1611 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1611_256x128_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611_ids4073_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
324
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1617.c
Normal file
324
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1617.c
Normal file
@@ -0,0 +1,324 @@
|
||||
/*
|
||||
|
||||
u8x8_d_uc1617.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2017, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_uc1617_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
//U8X8_C(0x0ad), /* display enable BW Mode*/
|
||||
U8X8_C(0x0af), /* display enable GS Mode*/
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1617_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ac), /* display off, enter sleep mode */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1617_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0c0), /* LCD Mapping */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1617_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0c6), /* LCD Mapping */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
//static uint8_t u8x8_upscale_4bit(uint8_t x) U8X8_NOINLINE;
|
||||
static uint8_t u8x8_upscale_4bit(uint8_t x)
|
||||
{
|
||||
uint8_t y = x;
|
||||
y |= (y << 4); // x = (x | (x << S[2])) & B[2];
|
||||
y &= 0x0f;
|
||||
y |= (y << 2); // x = (x | (x << S[1])) & B[1];
|
||||
y &= 0x33;
|
||||
y |= (y << 1); // x = (x | (x << S[0])) & B[0];
|
||||
y &= 0x55;
|
||||
|
||||
y |= (y << 1); // z = x | (y << 1);
|
||||
return y;
|
||||
}
|
||||
|
||||
static uint8_t u8x8_uc1617_tile_half_buffer[8];
|
||||
|
||||
static uint8_t *u8x8_convert_tile_for_uc1617_lower4bit(uint8_t *t)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t *pbuf = u8x8_uc1617_tile_half_buffer;
|
||||
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
*pbuf++ = u8x8_upscale_4bit(*t++);
|
||||
}
|
||||
return u8x8_uc1617_tile_half_buffer;
|
||||
}
|
||||
|
||||
static uint8_t *u8x8_convert_tile_for_uc1617_upper4bit(uint8_t *t)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t *pbuf = u8x8_uc1617_tile_half_buffer;
|
||||
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
*pbuf++ = u8x8_upscale_4bit((*t++)>>4);
|
||||
}
|
||||
return u8x8_uc1617_tile_half_buffer;
|
||||
}
|
||||
|
||||
#ifdef NOT_USED
|
||||
static uint8_t *u8x8_convert_tile_for_uc1617(uint8_t *t)
|
||||
{
|
||||
uint8_t i;
|
||||
uint16_t r;
|
||||
static uint8_t buf[16];
|
||||
uint8_t *pbuf = buf;
|
||||
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
r = u8x8_upscale_byte(*t++);
|
||||
*pbuf = r & 255;
|
||||
r >>= 8;
|
||||
pbuf+=8;
|
||||
*pbuf = r;
|
||||
pbuf-=7;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
uint8_t u8x8_d_uc1617_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, y, c, a;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
|
||||
|
||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
||||
y*=2;
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x060 | (x&15));
|
||||
u8x8_cad_SendCmd(u8x8, 0x070 | (x>>4));
|
||||
u8x8_cad_SendCmd(u8x8, 0x00 | (y));
|
||||
|
||||
#ifdef NOT_REQUIRED
|
||||
u8x8_cad_SendCmd(u8x8, 0xf8 ); /* disable window */
|
||||
u8x8_cad_SendCmd(u8x8, 0xf4 ); /* page start */
|
||||
u8x8_cad_SendCmd(u8x8, y );
|
||||
u8x8_cad_SendCmd(u8x8, 0xf5 ); /* x start */
|
||||
u8x8_cad_SendCmd(u8x8, x );
|
||||
u8x8_cad_SendCmd(u8x8, 0xf6 ); /* page end */
|
||||
u8x8_cad_SendCmd(u8x8, y );
|
||||
u8x8_cad_SendCmd(u8x8, 0xf7 ); /* x end */
|
||||
u8x8_cad_SendCmd(u8x8, 127 );
|
||||
u8x8_cad_SendCmd(u8x8, 0xf9 ); /* enable window */
|
||||
#endif
|
||||
|
||||
a = arg_int;
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 8, u8x8_convert_tile_for_uc1617_lower4bit(ptr));
|
||||
ptr += 8;
|
||||
x += 8;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
a--;
|
||||
} while( a > 0 );
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x060 | (x&15));
|
||||
u8x8_cad_SendCmd(u8x8, 0x070 | (x>>4));
|
||||
u8x8_cad_SendCmd(u8x8, 0x00 | (y+1));
|
||||
a = arg_int;
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, 8, u8x8_convert_tile_for_uc1617_upper4bit(ptr));
|
||||
ptr += 8;
|
||||
x += 8;
|
||||
c--;
|
||||
} while( c > 0 );
|
||||
a--;
|
||||
} while( a > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1617_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1617_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1617_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1617_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* uc1617 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*================================================*/
|
||||
/* JLX128128 */
|
||||
|
||||
static const uint8_t u8x8_d_uc1617_jlx128128_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0e2), /* reset */
|
||||
U8X8_DLY(10),
|
||||
|
||||
//U8X8_D1(0x0ff),
|
||||
U8X8_C(0x027), /* temperature compensation */
|
||||
U8X8_C(0x02b), /* panel loading: 13-18nF */
|
||||
|
||||
U8X8_C(0x02f), /* internal pump control */
|
||||
U8X8_C(0x0eb), /* bias=1/11 */
|
||||
U8X8_CA(0x081, 0x028), /* set contrast */
|
||||
//U8X8_C(0x0a9), /* used in display datasheet, but cmd not described in controller datasheet */
|
||||
|
||||
U8X8_CA(0x0f1, 0x07f), /* set COM end */
|
||||
U8X8_CA(0x0f2, 0x000), /* display line start */
|
||||
U8X8_CA(0x0f3, 127), /* display line end */
|
||||
U8X8_C(0x0a3), /* line rate */
|
||||
|
||||
U8X8_C(0x0d3), /* */
|
||||
U8X8_C(0x0d7), /* */
|
||||
|
||||
|
||||
//U8X8_C(0x0a5), /* all pixel on */
|
||||
|
||||
//U8X8_C(0x0d1), /* display pattern */
|
||||
U8X8_C(0x08b), /* auto increment */
|
||||
U8X8_C(0x0c0), /* LCD Mapping */
|
||||
|
||||
//U8X8_C(0x0ad), /* display enable BW Mode*/
|
||||
//U8X8_C(0x0af), /* display enable GS Mode*/
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1617_128x128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 10, /* uc1617 datasheet, page 54, actually 5 */
|
||||
/* pre_chip_disable_wait_ns = */ 10, /* uc1617 datasheet, page 54, actually 5 */
|
||||
/* reset_pulse_width_ms = */ 10,
|
||||
/* post_reset_wait_ms = */ 20, /* uc1617 datasheet, page 56 */
|
||||
/* sda_setup_time_ns = */ 24, /* uc1617 datasheet, page 54 */
|
||||
/* sck_pulse_width_ns = */ 45, /* half of cycle time uc1617 datasheet, page 54*/
|
||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30, /* uc1617 datasheet, page 52 */
|
||||
/* write_pulse_width_ns = */ 65, /* uc1617 datasheet, page 52 */
|
||||
/* tile_width = */ 16, /* width of 16*8=128 pixel */
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_uc1617_jlx128128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call common procedure first and handle messages there */
|
||||
if ( u8x8_d_uc1617_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1617_128x128_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1617_jlx128128_init_seq);
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
306
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1638.c
Normal file
306
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1638.c
Normal file
@@ -0,0 +1,306 @@
|
||||
/*
|
||||
|
||||
u8x8_d_uc1638.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
Support for the UC1638 controller
|
||||
|
||||
20 Jun 2021:
|
||||
The u8x8_d_uc1638_192x96 is tested and works.
|
||||
The u8x8_d_uc1638_160x128 will probably not work, there is no display to test this
|
||||
WARNING; The u8x8_d_uc1638_160x128 also has an inverted CS signal !!!
|
||||
Changed the SPI mode from 3 to 0, because it work nicely with mode 0
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_uc1638_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0c9, 0x0ad), /* display on */ /* UC1638 B/W mode */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1638_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_CA(0x0c9, 0x0ac), /* display off */ /* UC1638 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1638_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0c2), /* LCD Mapping */ /* UC1638*/
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1638_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0c4), /* LCD Mapping */ /* UC1638*/
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_uc1638_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x += u8x8->x_offset & 15;
|
||||
x *= 8;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x004); /* UC1638 */
|
||||
u8x8_cad_SendArg(u8x8, x);
|
||||
|
||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
||||
y += u8x8->x_offset >> 4;
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x060 | (y&15)); /* UC1638 */
|
||||
u8x8_cad_SendCmd(u8x8, 0x070 | (y>>4)); /* UC1638 */
|
||||
|
||||
|
||||
u8x8_cad_SendCmd(u8x8, 0x001); /* UC1638 */
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
/* handled in the calling procedure
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1638_128x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1638_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1638_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1638_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1638_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int ); /* uc1638 has range from 0 to 255 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*================================================*/
|
||||
/* uc1638 160x128 */
|
||||
|
||||
/* values taken from uc1608 */
|
||||
static const u8x8_display_info_t u8x8_uc1638_160x128_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 1, /* uc1638 has high active CS */
|
||||
/* chip_disable_level = */ 0,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 10, /* */
|
||||
/* pre_chip_disable_wait_ns = */ 20, /* */
|
||||
/* reset_pulse_width_ms = */ 5, /* */
|
||||
/* post_reset_wait_ms = */ 150,
|
||||
/* sda_setup_time_ns = */ 25, /* */
|
||||
/* sck_pulse_width_ns = */ 65, /* */
|
||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30, /* */
|
||||
/* write_pulse_width_ns = */ 35, /* */
|
||||
/* tile_width = */ 20, /* width of 20*8=160 pixel */
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 0, /* lower nibble: x offset, upper nibble: y offset */
|
||||
/* flipmode_x_offset = */ 0, /* lower nibble: x offset, upper nibble: y offset */
|
||||
/* pixel_width = */ 160,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1638_160x128_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_CA(0x0e1, 0x0e2), /* software reset */ /* UC1638*/
|
||||
U8X8_END_TRANSFER(), /* disable chip, requirement for I2C */
|
||||
U8X8_DLY(5), /* 5 ms */
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x024), /* set temp comp*/
|
||||
U8X8_C(0x0c0), /* mirror y and mirror x */ /* WAS: c2 */
|
||||
U8X8_C(0x0a2), /* line rate */
|
||||
U8X8_C(0x0d6), /* gray scale 2 */
|
||||
U8X8_C(0x0eb), /* set bias*/
|
||||
U8X8_C(0x095), /* set 1 bit per pixel, pattern 0*/
|
||||
U8X8_C(0x089), /* set auto increment, low bits are AC2 AC1 AC0 */ /* WAS 89 */
|
||||
|
||||
|
||||
U8X8_CA(0x081, 0x0a0), /* set contrast */ /* UC1638*/
|
||||
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_uc1638_160x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call common procedure first and handle messages there */
|
||||
if ( u8x8_d_uc1638_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1638_160x128_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1638_160x128_init_seq);
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*================================================*/
|
||||
|
||||
/* LG192962-DW-V33, uc1638 192x96, https://github.com/olikraus/u8g2/issues/371 */
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1638_192x96_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0, /* low active CS for this display */
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 10, /* */
|
||||
/* pre_chip_disable_wait_ns = */ 20, /* */
|
||||
/* reset_pulse_width_ms = */ 5, /* */
|
||||
/* post_reset_wait_ms = */ 150,
|
||||
/* sda_setup_time_ns = */ 25, /* */
|
||||
/* sck_pulse_width_ns = */ 65, /* */
|
||||
/* sck_clock_hz = */ 2000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30, /* */
|
||||
/* write_pulse_width_ns = */ 35, /* */
|
||||
/* tile_width = */ 24, /* width of 24*8=192 pixel */
|
||||
/* tile_hight = */ 12,
|
||||
/* default_x_offset = */ 8*16+0, /* lower nibble: x offset, upper nibble: y offset */
|
||||
/* flipmode_x_offset = */ 0*16+6, /* lower nibble: x offset, upper nibble: y offset */
|
||||
/* pixel_width = */ 192,
|
||||
/* pixel_height = */ 96
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1638_192x96_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_CA(0x0e1, 0x0e2), /* software reset */ /* UC1638*/
|
||||
U8X8_DLY(5), /* 5 ms */
|
||||
|
||||
U8X8_C(0x024), /* set temp comp*/
|
||||
U8X8_C(0x0c2), /* mirror y and mirror x */
|
||||
U8X8_C(0x0a2), /* line rate */
|
||||
U8X8_C(0x02d), /* charge pump */
|
||||
U8X8_C(0x0ea), /* set bias*/
|
||||
U8X8_CA(0x081, 160), /* set contrast */
|
||||
//U8X8_C(0x0d6), /* gray scale 2 */
|
||||
U8X8_C(0x095), /* set 1 bit per pixel, pattern 0*/
|
||||
U8X8_C(0x086), /* COM scan */
|
||||
U8X8_CA(0x0f1, 159), /* COM End*/
|
||||
U8X8_C(0x089), /* set auto increment, low bits are AC2 AC1 AC0 */ /* WAS 89 */
|
||||
//U8X8_C(0x086), /* scan function 0x86 or 0x87: no effect*/
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_uc1638_192x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
/* call common procedure first and handle messages there */
|
||||
if ( u8x8_d_uc1638_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
||||
{
|
||||
/* msg not handled, then try here */
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1638_192x96_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1638_192x96_init_seq);
|
||||
break;
|
||||
default:
|
||||
return 0; /* msg unknown */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
203
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1701_dogs102.c
Normal file
203
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1701_dogs102.c
Normal file
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
|
||||
u8x8_d_uc1701_dogs102.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_uc1701_dogs102_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0e2), /* soft reset */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_C(0x040), /* set display start line to 0 */
|
||||
|
||||
U8X8_C(0x0a1), /* ADC set to reverse */
|
||||
U8X8_C(0x0c0), /* common output mode */
|
||||
// Flipmode
|
||||
//U8X8_C(0x0a0), /* ADC set to reverse */
|
||||
//U8X8_C(0x0c8), /* common output mode */
|
||||
|
||||
U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */
|
||||
U8X8_C(0x0a2), /* LCD bias 1/9 */
|
||||
U8X8_C(0x02f), /* all power control circuits on */
|
||||
U8X8_C(0x027), /* regulator, booster and follower */
|
||||
U8X8_CA(0x081, 0x00e), /* set contrast, contrast value, EA default: 0x010, previous value for S102: 0x0e */
|
||||
U8X8_C(0x0fa), /* Set Temp compensation */
|
||||
U8X8_C(0x090), /* 0.11 deg/c WP Off WC Off*/
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1701_dogs102_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a4), /* all pixel off, issue 142 */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1701_dogs102_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1701_dogs102_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1701_dogs102_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1701_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 5,
|
||||
/* pre_chip_disable_wait_ns = */ 5,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 12,
|
||||
/* sck_pulse_width_ns = */ 75, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30,
|
||||
/* write_pulse_width_ns = */ 40,
|
||||
/* tile_width = */ 13, /* width of 13*8=104 pixel */
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 30,
|
||||
/* pixel_width = */ 102,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_uc1701_ea_dogs102(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1701_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int >> 2 ); /* uc1701 has range from 0 to 63 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
/*
|
||||
The following if condition checks the hardware limits of the uc1701
|
||||
controller: It is not allowed to write beyond the display limits.
|
||||
This is in fact an issue within flip mode.
|
||||
*/
|
||||
if ( c + x > 132u )
|
||||
{
|
||||
c = 132u;
|
||||
c -= x;
|
||||
}
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
205
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1701_mini12864.c
Normal file
205
MilliOhmMeter_FW/lib/U8g2/src/clib/u8x8_d_uc1701_mini12864.c
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
|
||||
u8x8_d_uc1701_mini12864.c (dealextreme, displays from ebay MP3 players)
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8x8_d_uc1701_mini12864_init_seq[] = {
|
||||
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
||||
U8X8_C(0x0e2), /* soft reset */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_C(0x040), /* set display start line to 0 */
|
||||
|
||||
U8X8_C(0x0a0), /* ADC set to reverse */
|
||||
U8X8_C(0x0c8), /* common output mode */
|
||||
|
||||
U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */
|
||||
U8X8_C(0x0a2), /* LCD bias 1/9 */
|
||||
U8X8_C(0x02f), /* all power control circuits on */
|
||||
U8X8_C(0x0f8), /* set booster ratio to */
|
||||
U8X8_C(0x000), /* 4x */
|
||||
U8X8_C(0x023), /* set V0 voltage resistor ratio to large */
|
||||
U8X8_C(0x081), /* set contrast */
|
||||
U8X8_C(0x027), /* contrast value */
|
||||
U8X8_C(0x0ac), /* indicator */
|
||||
// 0x000, /* disable */
|
||||
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */
|
||||
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1701_mini12864_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a4), /* all pixel off, issue 142 */
|
||||
U8X8_C(0x0af), /* display on */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1701_mini12864_powersave1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0ae), /* display off */
|
||||
U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1701_mini12864_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_uc1701_mini12864_flip1_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1701_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 5,
|
||||
/* pre_chip_disable_wait_ns = */ 5,
|
||||
/* reset_pulse_width_ms = */ 1,
|
||||
/* post_reset_wait_ms = */ 6,
|
||||
/* sda_setup_time_ns = */ 12,
|
||||
/* sck_pulse_width_ns = */ 75, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 0, /* active high, rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 30,
|
||||
/* write_pulse_width_ns = */ 40,
|
||||
/* tile_width = */ 16, /* width of 16*8=128 pixel */
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 4,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_uc1701_mini12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1701_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_mini12864_init_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_mini12864_powersave0_seq);
|
||||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_mini12864_powersave1_seq);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
if ( arg_int == 0 )
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_mini12864_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_mini12864_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
||||
u8x8_cad_SendArg(u8x8, arg_int >> 2 ); /* uc1701 has range from 0 to 63 */
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
#endif
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
x *= 8;
|
||||
x += u8x8->x_offset;
|
||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
/*
|
||||
The following if condition checks the hardware limits of the uc1701
|
||||
controller: It is not allowed to write beyond the display limits.
|
||||
This is in fact an issue within flip mode.
|
||||
|
||||
bug: this check should be inside the while loop, see u8x8_d_pcd8544_84x48.c
|
||||
*/
|
||||
if ( c + x > 132u )
|
||||
{
|
||||
c = 132u;
|
||||
c -= x;
|
||||
}
|
||||
do
|
||||
{
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ void u8x8_d_helper_display_init(u8x8_t *u8x8)
|
||||
{
|
||||
/* 2) apply port directions to the GPIO lines and apply default values for the IO lines*/
|
||||
u8x8_gpio_Init(u8x8);
|
||||
u8x8_cad_Init(u8x8);
|
||||
u8x8_cad_Init(u8x8); /* this will also call U8X8_MSG_BYTE_INIT, byte init will NOT call GPIO_INIT */
|
||||
|
||||
/* 3) do reset */
|
||||
u8x8_gpio_SetReset(u8x8, 1);
|
||||
@@ -95,6 +95,43 @@ void u8x8_SetupMemory(u8x8_t *u8x8)
|
||||
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SETUP_MEMORY, 0, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
This will just init the display interface, compared to InitDisplay, it will not issue a reset and also not upload the init code.
|
||||
Comparison:
|
||||
Call u8x8_InitInterface u8x8_InitDisplay
|
||||
Init Interface yes yes
|
||||
Reset Display no yes
|
||||
Upload Display Init Code no yes
|
||||
|
||||
u8x8_InitInterface() is an alternative function to u8x8_InitDisplay(). Do not call both.
|
||||
|
||||
*/
|
||||
void u8x8_InitInterface(u8x8_t *u8x8)
|
||||
{
|
||||
u8x8_gpio_Init(u8x8);
|
||||
u8x8_cad_Init(u8x8); /* this will also call U8X8_MSG_BYTE_INIT, byte init will NOT call GPIO_INIT */
|
||||
}
|
||||
|
||||
/*
|
||||
This will sent the display init message to the display.
|
||||
The display itself will then call u8x8_d_helper_display_init() from above. This includes:
|
||||
GPIO Init (set port directions)
|
||||
BYTE init (part of CAD init: which may set some levels)
|
||||
CAD init (which will set things like I2C default address)
|
||||
Issue a reset to the display: This will usually turn off the display
|
||||
Additonally each display will set the init code to the display, which will also turn of the display in most cases (Arduino code disable power save mode later)
|
||||
|
||||
Actually this procedure should be better called InitInterfaceAndDisplay, because it actually does both.
|
||||
(actually u8x8_InitInterface() is not called directly but only u8x8_gpio_Init and u8x8_cad_Init which
|
||||
in turn is called by u8x8_InitInterface())
|
||||
|
||||
|
||||
InitDisplay is called by the Arduino begin() function
|
||||
|
||||
In some cases it is not required to init the display (for example if the display is already running, but the controller comes out of deep sleep mode).
|
||||
Then InitDisplay can be skipped, but u8x8_InitInterface() (== u8x8_gpio_Init() and u8x8_cad_Init()) need to be executed.
|
||||
|
||||
*/
|
||||
void u8x8_InitDisplay(u8x8_t *u8x8)
|
||||
{
|
||||
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_INIT, 0, NULL);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user