Erik van de Coevering / UC1701

Dependents:   Opensmart_LCD_UC1701

UC1701.h

Committer:
Anaesthetix
Date:
2016-12-18
Revision:
0:a8cfaf48d064
Child:
1:f396898c2963

File content as of revision 0:a8cfaf48d064:

/**
 * This is a simple library for UC1701 controlled graphic LCD's. 
 * Written for a cheap OPEN-SMART 1.8" 128x64 display
 * See      http://www.dx.com/p/open-smart-1-8-128-64-lcd-display-breakout-module-w-blue-backlit-444694
 
 * Written by:  Erik van de Coevering
 * With special thanks to Tim Barr from whom I've reused some code
 * Use this code in whatever way you like, as long as it stays free of charge!
 *
 * Copyright (c) 2016
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * 
 */

#ifndef UC1701_H
#define UC1701_H

#include "mbed.h"
#include "font_4x5.h"
#include "font_5x8.h"
#include "font_6x6.h"
#include "font_6x8.h"
#include "font_7x7.h"
#include "font_8x8.h"
#include "font_8x8_1.h"
#include "test_15x16.h"
#include "bold_font.h"
#include "font2d_hunter.h"
#include "font2d_formplex12.h"
#include "biohazard.h"
#include "highvoltage.h"
#include "einstein.h"
#include "test.h"
#include "copter.h"

#define LCDWIDTH 128
#define LCDHEIGHT 64
#define LCDPAGES 8

class UC1701
{
public:

    // Constructor
    UC1701(SPI &spi, DigitalOut &lcd_cs, DigitalOut &cd);

    // Initialize LCD
    void init(void);

    // Place cursor at position
    void setCursor(char column, char line);

    // Clear screen
    void clear(void);

    // Fill screen by writing each pixel -> used for optimizing. Use command 0xA5
    void fill(void);
    
    // Write text to LCD where font format is a 2-dimensional array (only 96x8, 8x8 pixel fonts supported)
    void writeText2d(char column, char page, const char font_address[96][8], const char *text, int size);

    // Write text to LCD where font format is a 1-dimensional array
    void writeText(char column, char page, const char *font_address, const char *str, const uint8_t size);

    // Draw a 128x64 pixel bitmap
    void drawBitmap(const char *data);

private:

    SPI         *_lcd;
    DigitalOut  *_lcd_cs;
    DigitalOut  *_lcd_cd;
    uint8_t     _lcdbuffer[LCDWIDTH*LCDPAGES];

};

#endif