uc1601_controllers - Anobium/Great-Cow-BASIC-Help GitHub Wiki

UC1601 Controllers

This section covers GLCD devices that use the UC1601 graphics controller.

The UC1601 is an advanced high-voltage mixed signal CMOS IC, especially designed for the display needs of ultra-low power hand-held devices.

The UC1601 embeds with contrast control, display RAM and oscillator, which reduces the number of external components and power consumption.   It has 256-step brightness control. Data/Commands are sent from general MCU through the hardware selectable 6800/8000 series compatible Parallel Interface, I2C interface or Serial Peripheral Interface. It is suitable for many compact portable applications, such as mobile phone sub-display, MP3 player and calculator, etc.

The UC1601 library supports 132 * 22 pixels.   The UC1601 library supports monochrome devices.

graphic

The UC1601 can operate in three modes.   Full GLCD mode, Low Memory GLCD mode or Text/JPG mode the full GLCD mode requires a minimum of 396 bytes or 128 bytes for the respective modes.  For microcontrollers with limited memory the third mode of operation - Text mode. These can be selected by setting the correct constant.

To use the UC1601 driver simply include the following in your user code. This will initialise the driver.

The Great Cow BASIC constants shown below control the configuration of the UC1601 controller.    Great Cow BASIC supports hardware I2C & software I2C connectivity - this is shown in the tables below.

To use the UC1601 drivers simply include one of the following configuration.

    'An I2C configuration
    #include <glcd.h>

    #define GLCD_TYPE GLCD_TYPE_UC1601
    #define GLCD_I2C_Address      0x70                   'I2C address
    #define GLCD_RESET            portc.0                'Hard Reset pin connection
    #define GLCD_PROTECTOVERRUN
    #define GLCD_OLED_FONT

    ; ----- Define Hardware settings for I2C
    ' Define I2C settings - CHANGE PORTS
    #define I2C_MODE Master
    #define I2C_DATA PORTb.5
    #define I2C_CLOCK PORTb.7
    #define I2C_DISABLE_INTERRUPTS ON

The Great Cow BASIC constants for control display characteristics are shown in the table below.

Constants Controls Options
GLCD_TYPE GLCD_TYPE_UC1601 Required
GLCD_I2C_Address I2C address of the GLCD. Fixed at 0x70.

The Great Cow BASIC constants for control display characteristics are shown in the table below.

Constants Controls Default

GLCD_WIDTH

The width parameter of the GLCD

132

GLCD_HEIGHT

The height parameter of the GLCD

22

GLCD_PROTECTOVERRUN

Define this constant to restrict pixel operations with the pixel limits

Recommended

GLCD_TYPE_UC1601_CHARACTER_MODE_ONLY

Specifies that the display controller will operate in text mode and BMP draw mode only.
For microcontrollers with low RAM this will be set be default.
When selected ONLY text related commands are suppored. For grapical commands you must have sufficient memory to use Full GLCD mode or use GLCD_TYPE_UC1601_LOWMEMORY_GLCD_MODE

Optional

GLCD_TYPE_UC1601_LOWMEMORY_GLCD_MODE

Specifies that the display controller will operate in Low Memory mode.

Optional

GLCD_OLED_FONT

Specifies the use of the optional OLED font set.

The GLCDfntDefaultsize can be set to 1 or 2 only.

GLCDfntDefaultsize= 1. A small 8 height pixel font with variable width. GLCDfntDefaultsize= 2. A larger 10 width * 16 height pixel font.

Optional

The Great Cow BASIC variables for control display characteristics are shown in the table below. These variables control the user definable parameters of a specific GLCD.

Variable Purpose Type

GLCDBackground

GLCD background state.

A monochrome value.
For mono GLCDs the default is White or 0x0001.

GLCDForeground

Color of GLCD foreground.

A monochrome value.
For mono GLCDs the default is non-white or 0x0000.

GLCDFontWidth

Width of the current GLCD font.

Default is 6 pixels.

GLCDfntDefault

Size of the current GLCD font.

Default is 0.

This equates to the standard GCB font set.

GLCDfntDefaultsize

Size of the current GLCD font.

Default is 1.

This equates to the 8 pixel high.

The Great Cow BASIC commands supported for this GLCD are shown in the table below.

Command Purpose Example
GLCDCLS Clear screen of GLCD GLCDCLS
GLCDPrint Print string of characters on GLCD using GCB font set GLCDPrint( Xposition, Yposition, Stringvariable )
GLCDDrawChar Print character on GLCD using GCB font set GLCDDrawChar( Xposition, Yposition, CharCode )
GLCDDrawString Print characters on GLCD using GCB font set GLCDDrawString( Xposition, Yposition, Stringvariable )
Box Draw a box on the GLCD to a specific size Box ( Xposition1, Yposition1, Xposition2, Yposition2, [Optional In LineColour as 0 or 1] )
FilledBox Draw a box on the GLCD to a specific size that is filled with the foreground colour. FilledBox (Xposition1, Yposition1, Xposition2, Yposition2, [Optional In LineColour 0 or 1] )
Line Draw a line on the GLCD to a specific length that is filled with the specific attribute. Line ( Xposition1, Yposition1, Xposition2, Yposition2, [Optional In LineColour 0 or 1] )
PSet Set a pixel on the GLCD at a specific position that is set with the specific attribute. PSet(Xposition, Yposition, Pixel Colour 0 or 1)
GLCD_Open_PageTransaction Commence a series of GLCD commands when in low memory mode. Must be followed a GLCD_Close_PageTransaction command. GLCD_Close_PageTransaction 0, 3 where 0 and 3 are the range of pages to be updated
GLCD_Close_PageTransaction Commence a series of GLCD commands when in low memory mode. Must follow a GLCD_Open_PageTransaction command.  
Open_Transaction_UC1601 Send command instruction to GLCD. Handles I2C and SPI protocols. Transaction must be closed by using Close_Transaction_UC1601
Open_Transaction_Data_UC1601 Send data instruction to GLCD. Handles I2C and SPI protocols. Transaction must be closed by using Close_Transaction_UC1601
Write_Transaction_Data_UC1601 Send transactional, a stream of, data to GLCD. Transaction must be opened and closed by using transaction commands.
Close_Transaction_UC1601 Close the communications to the GLCD. Transaction must be opened by using Open_Transaction_UC1601 or Open_Transaction_Data_UC1601

The Great Cow BASIC specific commands for this GLCD are shown in the table below.

Command Purpose

Stopscroll_UC1601

Stops all scrolling

Startscroll_UC1601 ( start )

Activates a vertical scroll for rows start.

GLCDSetContrast ( contrast_state )

Sets the constrast between 0 and 255. The contrast increases as the value increases.
Parameter is contrast value

For a UC1601 datasheet, please refer here.

This example shows how to drive a UC1601 based Graphic I2C LCD module with the built in commands of Great Cow BASIC using Full Mode GLCD

        ; ----- Configuration
        #chip 16f18446, 32
        #option explicit


    ; ----- Define GLCD Hardware settings
        #include <glcd.h>

        #define GLCD_TYPE GLCD_TYPE_UC1601
        #define GLCD_I2C_Address      0x70                   'I2C address
        #define GLCD_RESET            portc.0                'Hard Reset pin connection
        #define GLCD_PROTECTOVERRUN
        #define GLCD_OLED_FONT

    ; ----- Define Hardware settings

        ' Define I2C settings - CHANGE PORTS
        #define I2C_MODE Master
        #define I2C_DATA PORTb.5
        #define I2C_CLOCK PORTb.7
        #define I2C_DISABLE_INTERRUPTS ON

    ; ----- Define variables

    ; ----- Main program

        'You can treat the GLCD like an LCD....
        GLCDPrintStringLN "User the GLCD like an LCD...."
        GLCDPrintStringLN "The GLCDPrintString commands...."
        GLCDPrintString "Enjoy....."
        wait 4 s

    end

This example shows how to drive a UC1601 based Graphic I2C LCD module with the built in commands of Great Cow BASIC using Low Memory Mode GLCD.
Note the use of GLCD_Open_PageTransaction and GLCD_Close_PageTransaction to support the Low Memory Mode of operation and the contraining of all GLCD commands with the transaction commands. The use Low Memory Mode GLCD the two defines GLCD_TYPE_UC1601_LOWMEMORY_GLCD_MODE and GLCD_TYPE_UC1601_CHARACTER_MODE_ONLY are included in the user program.

    #chip mega328p,16
    #include <glcd.h>

    ; ----- Define Hardware settings
    ' Define I2C settings
    #define HI2C_BAUD_RATE 400
    #define HI2C_DATA
    HI2CMode Master

    ; ----- Define GLCD Hardware settings
    #define GLCD_TYPE GLCD_TYPE_UC1601
    #define GLCD_TYPE_UC1601_LOWMEMORY_GLCD_MODE
    #define GLCD_TYPE_UC1601_CHARACTER_MODE_ONLY

    dim outString as string * 21

    GLCDCLS

    'To clarify - page udpates
    '0,7 correspond with the Text Lines from 0 to 3 on a 22 Pixel Display
    'In this example Code would be GLCD_Open_PageTransaction 0,1 been enough
    'But it is allowed to use GLCD_Open_PageTransaction 0,3 to show the full screen update
    GLCD_Open_PageTransaction 0,3
       GLCDPrint 0, 0, "Great Cow BASIC"
       GLCDPrint (0, 16, "Anobium 2021")
    GLCD_Close_PageTransaction

    end

For more help, see GLCDCLS, GLCDDrawChar, GLCDPrint, GLCDReadByte, GLCDWriteByte or Pset

Supported in <GLCD.H>

⚠️ **GitHub.com Fallback** ⚠️