Line buffer mode. sammple code with MIP8F_SPI_Ver40

Dependencies:   MIP8F_SPI_Ver40 mbed

Dependents:   MIP8f_FRDM_TransferMode_sample MIP8f_FRDM_Animation_sample

Introduction

Line buffer mode sample with MIP8F_SPI_Ver40 Display some color and monochrome bitmap.

Other information , please refer to https://os.mbed.com/teams/JapanDisplayInc/code/MIP8f_FRDM_sample/

Usage

Copy Setting File and Image to micro SD-CARD. (Same setting File and bitmap of MIP8f_FRDM_sample.)

a) Download the following file corresponding to the target panel, and rename file identifier (.bin -> .zip), and unzip the file on micro SD Card's root directory.

b) Insert micro SD-CARD to FRDM-K64F. c) Upload binary file to FRDM-K64F.and push Reset Button.

Other information

refer to Usage on https://os.mbed.com/teams/JapanDisplayInc/code/MIP8f_FRDM_sample/

this Sample Code (.bin)

/media/uploads/JDI_Mbed_Team/mip8f_frdm_linebuffer_sample.k64f.bin

Committer:
JDI_Mbed_Team
Date:
Tue Nov 06 03:57:02 2018 +0000
Revision:
13:855affe061f7
Parent:
0:33fe30a2b785
Line buffer mode. sample code with MIP8F_SPI_Ver40

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JDI_Mbed_Team 0:33fe30a2b785 1 /* mbed Microcontroller Library - MemFileSystem
JDI_Mbed_Team 0:33fe30a2b785 2 * Copyright (c) 2008, sford
JDI_Mbed_Team 0:33fe30a2b785 3 */
JDI_Mbed_Team 0:33fe30a2b785 4
JDI_Mbed_Team 0:33fe30a2b785 5
JDI_Mbed_Team 0:33fe30a2b785 6 #ifndef MBED_MEMFILESYSTEM_H
JDI_Mbed_Team 0:33fe30a2b785 7 #define MBED_MEMFILESYSTEM_H
JDI_Mbed_Team 0:33fe30a2b785 8
JDI_Mbed_Team 0:33fe30a2b785 9 #include "FATFileSystem.h"
JDI_Mbed_Team 0:33fe30a2b785 10
JDI_Mbed_Team 0:33fe30a2b785 11 namespace mbed
JDI_Mbed_Team 0:33fe30a2b785 12 {
JDI_Mbed_Team 0:33fe30a2b785 13
JDI_Mbed_Team 0:33fe30a2b785 14 class MemFileSystem : public FATFileSystem
JDI_Mbed_Team 0:33fe30a2b785 15 {
JDI_Mbed_Team 0:33fe30a2b785 16 public:
JDI_Mbed_Team 0:33fe30a2b785 17
JDI_Mbed_Team 0:33fe30a2b785 18 // 2000 sectors, each 512 bytes (malloced as required)
JDI_Mbed_Team 0:33fe30a2b785 19 char *sectors[2000];
JDI_Mbed_Team 0:33fe30a2b785 20
JDI_Mbed_Team 0:33fe30a2b785 21 MemFileSystem(const char* name) : FATFileSystem(name) {
JDI_Mbed_Team 0:33fe30a2b785 22 memset(sectors, 0, sizeof(sectors));
JDI_Mbed_Team 0:33fe30a2b785 23 }
JDI_Mbed_Team 0:33fe30a2b785 24
JDI_Mbed_Team 0:33fe30a2b785 25 virtual ~MemFileSystem() {
JDI_Mbed_Team 0:33fe30a2b785 26 for(int i = 0; i < 2000; i++) {
JDI_Mbed_Team 0:33fe30a2b785 27 if(sectors[i]) {
JDI_Mbed_Team 0:33fe30a2b785 28 free(sectors[i]);
JDI_Mbed_Team 0:33fe30a2b785 29 }
JDI_Mbed_Team 0:33fe30a2b785 30 }
JDI_Mbed_Team 0:33fe30a2b785 31 }
JDI_Mbed_Team 0:33fe30a2b785 32
JDI_Mbed_Team 0:33fe30a2b785 33 // read a sector in to the buffer, return 0 if ok
JDI_Mbed_Team 0:33fe30a2b785 34 virtual int disk_read(char *buffer, int sector) {
JDI_Mbed_Team 0:33fe30a2b785 35 if(sectors[sector] == 0) {
JDI_Mbed_Team 0:33fe30a2b785 36 // nothing allocated means sector is empty
JDI_Mbed_Team 0:33fe30a2b785 37 memset(buffer, 0, 512);
JDI_Mbed_Team 0:33fe30a2b785 38 } else {
JDI_Mbed_Team 0:33fe30a2b785 39 memcpy(buffer, sectors[sector], 512);
JDI_Mbed_Team 0:33fe30a2b785 40 }
JDI_Mbed_Team 0:33fe30a2b785 41 return 0;
JDI_Mbed_Team 0:33fe30a2b785 42 }
JDI_Mbed_Team 0:33fe30a2b785 43
JDI_Mbed_Team 0:33fe30a2b785 44 // write a sector from the buffer, return 0 if ok
JDI_Mbed_Team 0:33fe30a2b785 45 virtual int disk_write(const char *buffer, int sector) {
JDI_Mbed_Team 0:33fe30a2b785 46 // if buffer is zero deallocate sector
JDI_Mbed_Team 0:33fe30a2b785 47 char zero[512];
JDI_Mbed_Team 0:33fe30a2b785 48 memset(zero, 0, 512);
JDI_Mbed_Team 0:33fe30a2b785 49 if(memcmp(zero, buffer, 512)==0) {
JDI_Mbed_Team 0:33fe30a2b785 50 if(sectors[sector] != 0) {
JDI_Mbed_Team 0:33fe30a2b785 51 free(sectors[sector]);
JDI_Mbed_Team 0:33fe30a2b785 52 sectors[sector] = 0;
JDI_Mbed_Team 0:33fe30a2b785 53 }
JDI_Mbed_Team 0:33fe30a2b785 54 return 0;
JDI_Mbed_Team 0:33fe30a2b785 55 }
JDI_Mbed_Team 0:33fe30a2b785 56 // else allocate a sector if needed, and write
JDI_Mbed_Team 0:33fe30a2b785 57 if(sectors[sector] == 0) {
JDI_Mbed_Team 0:33fe30a2b785 58 char *sec = (char*)malloc(512);
JDI_Mbed_Team 0:33fe30a2b785 59 if(sec==0) {
JDI_Mbed_Team 0:33fe30a2b785 60 return 1; // out of memory
JDI_Mbed_Team 0:33fe30a2b785 61 }
JDI_Mbed_Team 0:33fe30a2b785 62 sectors[sector] = sec;
JDI_Mbed_Team 0:33fe30a2b785 63 }
JDI_Mbed_Team 0:33fe30a2b785 64 memcpy(sectors[sector], buffer, 512);
JDI_Mbed_Team 0:33fe30a2b785 65 return 0;
JDI_Mbed_Team 0:33fe30a2b785 66 }
JDI_Mbed_Team 0:33fe30a2b785 67
JDI_Mbed_Team 0:33fe30a2b785 68 // return the number of sectors
JDI_Mbed_Team 0:33fe30a2b785 69 virtual int disk_sectors() {
JDI_Mbed_Team 0:33fe30a2b785 70 return sizeof(sectors)/sizeof(sectors[0]);
JDI_Mbed_Team 0:33fe30a2b785 71 }
JDI_Mbed_Team 0:33fe30a2b785 72
JDI_Mbed_Team 0:33fe30a2b785 73 };
JDI_Mbed_Team 0:33fe30a2b785 74
JDI_Mbed_Team 0:33fe30a2b785 75 }
JDI_Mbed_Team 0:33fe30a2b785 76
JDI_Mbed_Team 0:33fe30a2b785 77 #endif