Draw the character of the ASCII code.
Dependents: mbed-os_Watson-IoT_ZXing_sample mbed-os_Watson-IoT_ZXing_sample MovPlayer GR-PEACH_HVC-P2_sample_client ... more
Fork of AsciiFont by
AsciiFont
This is a library to draw the ASCII font characters.
Example
#include "mbed.h" #include "AsciiFont.h" #define WIDTH (12) #define HEIGHT (16) #define BYTE_PER_PIXEL (1u) #define STRIDE (((WIDTH * BYTE_PER_PIXEL) + 7u) & ~7u) //multiple of 8 uint8_t text_field[STRIDE * HEIGHT]; //for debug void print_text_field() { int idx = 0; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < STRIDE; j++) { printf("%02x", text_field[idx++]); } printf("\r\n"); } printf("\r\n"); } int main() { AsciiFont ascii_font(text_field, WIDTH, HEIGHT, STRIDE, BYTE_PER_PIXEL); ascii_font.Erase(0xcc); ascii_font.DrawStr("AB", 0, 0, 0x11, 1); ascii_font.DrawChar('C', AsciiFont::CHAR_PIX_WIDTH, AsciiFont::CHAR_PIX_HEIGHT, 0x22, 1); print_text_field(); //debug print ascii_font.Erase(); ascii_font.DrawStr("D", 0, 0, 0xef, 2); print_text_field(); //debug print ascii_font.Erase(0x11, 6, 0, 6, 8); print_text_field(); //debug print }
API
Import library
Public Member Functions |
|
AsciiFont (uint8_t *p_buf, int width, int height, int stride, int byte_per_pixel, uint32_t const colour=0) | |
Constructor: Initializes
AsciiFont
.
|
|
void | Erase () |
Erase text field.
|
|
void | Erase (uint32_t const colour) |
Erase text field.
|
|
void | Erase (uint32_t const colour, int x, int y, int width, int height) |
Erase text field.
|
|
int | DrawStr (char *str, int x, int y, uint32_t const colour, int font_size=1, uint16_t const max_char_num=0xffff) |
Draw a string.
|
|
bool | DrawChar (char c, int x, int y, uint32_t const colour, int font_size=1) |
Draw a character.
|
|
Static Public Attributes |
|
static const int | CHAR_PIX_WIDTH = 6 |
The pixel width of a character.
|
|
static const int | CHAR_PIX_HEIGHT = 8 |
The pixel height of a character.
|
ascii.h@5:1eaa4942db53, 2017-03-07 (annotated)
- Committer:
- dkato
- Date:
- Tue Mar 07 05:04:28 2017 +0000
- Revision:
- 5:1eaa4942db53
- Parent:
- 1:fc1b3db025d6
Added range check to Erase function.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dkato | 0:99222c303e8f | 1 | /****************************************************************************** |
dkato | 0:99222c303e8f | 2 | * DISCLAIMER |
dkato | 0:99222c303e8f | 3 | * This software is supplied by Renesas Electronics Corporation and is only |
dkato | 0:99222c303e8f | 4 | * intended for use with Renesas products. No other uses are authorized. This |
dkato | 0:99222c303e8f | 5 | * software is owned by Renesas Electronics Corporation and is protected under |
dkato | 0:99222c303e8f | 6 | * all applicable laws, including copyright laws. |
dkato | 0:99222c303e8f | 7 | * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING |
dkato | 0:99222c303e8f | 8 | * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT |
dkato | 0:99222c303e8f | 9 | * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE |
dkato | 0:99222c303e8f | 10 | * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. |
dkato | 0:99222c303e8f | 11 | * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS |
dkato | 0:99222c303e8f | 12 | * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE |
dkato | 0:99222c303e8f | 13 | * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR |
dkato | 0:99222c303e8f | 14 | * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE |
dkato | 0:99222c303e8f | 15 | * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
dkato | 0:99222c303e8f | 16 | * Renesas reserves the right, without notice, to make changes to this software |
dkato | 0:99222c303e8f | 17 | * and to discontinue the availability of this software. By using this software, |
dkato | 0:99222c303e8f | 18 | * you agree to the additional terms and conditions found by accessing the |
dkato | 0:99222c303e8f | 19 | * following link: |
dkato | 0:99222c303e8f | 20 | * http://www.renesas.com/disclaimer |
dkato | 0:99222c303e8f | 21 | * |
dkato | 1:fc1b3db025d6 | 22 | * Copyright (C) 2014 Renesas Electronics Corporation. All rights reserved. |
dkato | 1:fc1b3db025d6 | 23 | *******************************************************************************/ |
dkato | 1:fc1b3db025d6 | 24 | /******************************************************************************* |
dkato | 1:fc1b3db025d6 | 25 | * File Name : ascii.h |
dkato | 1:fc1b3db025d6 | 26 | * Device(s) : RZ/A1H (R7S721001) |
dkato | 1:fc1b3db025d6 | 27 | * Tool-Chain : GNUARM-NONEv14.02-EABI |
dkato | 1:fc1b3db025d6 | 28 | * H/W Platform : RSK+RZA1H CPU Board |
dkato | 0:99222c303e8f | 29 | * Description : This Header file contains the Macro Definitions & prototypes |
dkato | 0:99222c303e8f | 30 | * for the functions used in lcd.c |
dkato | 0:99222c303e8f | 31 | *******************************************************************************/ |
dkato | 0:99222c303e8f | 32 | /******************************************************************************* |
dkato | 0:99222c303e8f | 33 | * History : DD.MM.YYYY Version Description |
dkato | 1:fc1b3db025d6 | 34 | * : 21.10.2014 1.00 |
dkato | 0:99222c303e8f | 35 | *******************************************************************************/ |
dkato | 0:99222c303e8f | 36 | |
dkato | 0:99222c303e8f | 37 | /* Multiple inclusion prevention macro */ |
dkato | 0:99222c303e8f | 38 | #ifndef ASCII_H |
dkato | 0:99222c303e8f | 39 | #define ASCII_H |
dkato | 0:99222c303e8f | 40 | |
dkato | 0:99222c303e8f | 41 | /****************************************************************************** |
dkato | 0:99222c303e8f | 42 | Macro Definitions |
dkato | 0:99222c303e8f | 43 | ******************************************************************************/ |
dkato | 1:fc1b3db025d6 | 44 | extern const char g_ascii_table[][6]; |
dkato | 0:99222c303e8f | 45 | |
dkato | 1:fc1b3db025d6 | 46 | /* ASCII_H */ |
dkato | 1:fc1b3db025d6 | 47 | #endif |
dkato | 0:99222c303e8f | 48 | |
dkato | 0:99222c303e8f | 49 |