This Program is for MAPLE board with OLED and GPS/RTC module. OLED module(OB) : 128 x 128 pixels, 4K color GPS/RTC module(GB) : UP501 These module can buy Marutyu (http://www.marutsu.co.jp)

Dependencies:   mbed

Committer:
y_notsu
Date:
Sun Jun 05 15:10:48 2011 +0000
Revision:
0:58e40a872950

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
y_notsu 0:58e40a872950 1 // MARMEX OLED and GPS test program
y_notsu 0:58e40a872950 2 // Author : Yuji Notsu
y_notsu 0:58e40a872950 3 // Date : 30-Mar-2011
y_notsu 0:58e40a872950 4 // Revision : 0.0
y_notsu 0:58e40a872950 5
y_notsu 0:58e40a872950 6 /** A sample app of MARMEX_OB OLED screen drawing library
y_notsu 0:58e40a872950 7 *
y_notsu 0:58e40a872950 8 * @author Tedd
y_notsu 0:58e40a872950 9 * @version 0.51
y_notsu 0:58e40a872950 10 * @date 08-Apr-2011
y_notsu 0:58e40a872950 11 *
y_notsu 0:58e40a872950 12 * Released under the MIT License: http://mbed.org/license/mit
y_notsu 0:58e40a872950 13 *
y_notsu 0:58e40a872950 14 * MARMEX_OB_oled OLED screen drawing library for mbed
y_notsu 0:58e40a872950 15 * This code has been written based on sample code and advises
y_notsu 0:58e40a872950 16 * from Ochiai-san (Marutsu-Elec). Thank you!
y_notsu 0:58e40a872950 17 *
y_notsu 0:58e40a872950 18 * To build this code, "NokiaLCD" and "mbed" libraries are needed to be imported in a project.
y_notsu 0:58e40a872950 19 * NokiaLCD library : http://mbed.org/users/simon/libraries/NokiaLCD/
y_notsu 0:58e40a872950 20 */
y_notsu 0:58e40a872950 21
y_notsu 0:58e40a872950 22
y_notsu 0:58e40a872950 23 #include "mbed.h"
y_notsu 0:58e40a872950 24 #include "MARMEX_OB_oled.h"
y_notsu 0:58e40a872950 25 #include "imagedata.h"
y_notsu 0:58e40a872950 26 #include "gpsrtc.h"
y_notsu 0:58e40a872950 27
y_notsu 0:58e40a872950 28 // oled1 is for MARMEX_OB_oled board on MAPLE slot 1
y_notsu 0:58e40a872950 29 MARMEX_OB_oled oled1( p5, p7, p8, p30, p11 ); // mosi, sclk, cs, rst, power_control
y_notsu 0:58e40a872950 30
y_notsu 0:58e40a872950 31 void oled_image2(const unsigned int *ptr2);
y_notsu 0:58e40a872950 32
y_notsu 0:58e40a872950 33 int main() {
y_notsu 0:58e40a872950 34
y_notsu 0:58e40a872950 35 // Initialize RTC
y_notsu 0:58e40a872950 36 //
y_notsu 0:58e40a872950 37 // Init_RTC(1, 11, 05, 31, TUE, 00, 55, 00); // with adjustment
y_notsu 0:58e40a872950 38 //wait(1.0);
y_notsu 0:58e40a872950 39 // Init_RTC(0, 00, 00, 00, 000, 00, 00, 00); // without adjustment
y_notsu 0:58e40a872950 40 //
y_notsu 0:58e40a872950 41
y_notsu 0:58e40a872950 42 //Start up window (texe base)
y_notsu 0:58e40a872950 43 oled1.background( 0x000000 );
y_notsu 0:58e40a872950 44 oled1.cls();
y_notsu 0:58e40a872950 45 oled1.locate(0,1);
y_notsu 0:58e40a872950 46 oled1.printf("Takoruka OS");
y_notsu 0:58e40a872950 47 oled1.locate(0,2);
y_notsu 0:58e40a872950 48 oled1.printf("starting.");
y_notsu 0:58e40a872950 49 wait(1.0);
y_notsu 0:58e40a872950 50 oled1.printf(".");
y_notsu 0:58e40a872950 51 wait(1.0);
y_notsu 0:58e40a872950 52 oled1.printf(".");
y_notsu 0:58e40a872950 53 wait(1.0);
y_notsu 0:58e40a872950 54 oled1.printf(".");
y_notsu 0:58e40a872950 55 wait(1.0);
y_notsu 0:58e40a872950 56 oled1.locate(0,3);
y_notsu 0:58e40a872950 57 oled1.printf("done!");
y_notsu 0:58e40a872950 58
y_notsu 0:58e40a872950 59 //display Imade data of imagedata.h
y_notsu 0:58e40a872950 60 wait(1.0);
y_notsu 0:58e40a872950 61 oled1.cls();
y_notsu 0:58e40a872950 62 oled1.locate(0,0);
y_notsu 0:58e40a872950 63 oled_image2(Header1);
y_notsu 0:58e40a872950 64
y_notsu 0:58e40a872950 65 wait(1.0);
y_notsu 0:58e40a872950 66 oled1.cls();
y_notsu 0:58e40a872950 67
y_notsu 0:58e40a872950 68 sGPSRTC sGPSRTC_Data;
y_notsu 0:58e40a872950 69 sGPSRTC *psGPSRTC_Data;
y_notsu 0:58e40a872950 70
y_notsu 0:58e40a872950 71 while(1)
y_notsu 0:58e40a872950 72 {
y_notsu 0:58e40a872950 73 //Get GPSRTC data and display
y_notsu 0:58e40a872950 74 Get_GPGGA_Data(&sGPSRTC_Data);
y_notsu 0:58e40a872950 75 Get_RTC_Data(&sGPSRTC_Data);
y_notsu 0:58e40a872950 76 psGPSRTC_Data = &sGPSRTC_Data;
y_notsu 0:58e40a872950 77
y_notsu 0:58e40a872950 78 oled1.locate(0,1);
y_notsu 0:58e40a872950 79 oled1.foreground(0xff00ff);
y_notsu 0:58e40a872950 80 oled1.printf("RTC");
y_notsu 0:58e40a872950 81 oled1.locate(0,2);
y_notsu 0:58e40a872950 82 oled1.foreground(0x00ffff);
y_notsu 0:58e40a872950 83 oled1.printf("%02d/%02d/%02d(%s)",
y_notsu 0:58e40a872950 84 psGPSRTC_Data->bRTC_year, psGPSRTC_Data->bRTC_mon, psGPSRTC_Data->bRTC_day,
y_notsu 0:58e40a872950 85 Get_Week_String(psGPSRTC_Data->bRTC_week));
y_notsu 0:58e40a872950 86 oled1.locate(0,3);
y_notsu 0:58e40a872950 87 oled1.printf("%02d:%02d:%02d",
y_notsu 0:58e40a872950 88 psGPSRTC_Data->bRTC_hour, psGPSRTC_Data->bRTC_min, psGPSRTC_Data->bRTC_sec);
y_notsu 0:58e40a872950 89 oled1.locate(0,4);
y_notsu 0:58e40a872950 90 oled1.foreground(0xff0000);//Red
y_notsu 0:58e40a872950 91 oled1.printf("----------");
y_notsu 0:58e40a872950 92 oled1.foreground(0x00ffff); //Cyan
y_notsu 0:58e40a872950 93 oled1.foreground(0xff00ff);
y_notsu 0:58e40a872950 94 oled1.locate(0,5);
y_notsu 0:58e40a872950 95 oled1.printf("GPS");
y_notsu 0:58e40a872950 96 oled1.foreground(0xffff00); //Yellow
y_notsu 0:58e40a872950 97 oled1.locate(0,6);
y_notsu 0:58e40a872950 98 oled1.printf("UTC =");
y_notsu 0:58e40a872950 99 oled1.printf("%02d:%02d:%02d",
y_notsu 0:58e40a872950 100 psGPSRTC_Data->bGPS_UTC_hour, psGPSRTC_Data->bGPS_UTC_min, psGPSRTC_Data->bGPS_UTC_sec);
y_notsu 0:58e40a872950 101 oled1.locate(0,7);
y_notsu 0:58e40a872950 102 //oled1.foreground(0x00ffff); //Cyan
y_notsu 0:58e40a872950 103 oled1.printf("LAT =");
y_notsu 0:58e40a872950 104 oled1.printf("%c %02d:%02d:%02d", psGPSRTC_Data->cGPS_LAT,
y_notsu 0:58e40a872950 105 psGPSRTC_Data->bGPS_LAT_deg, psGPSRTC_Data->bGPS_LAT_min, psGPSRTC_Data->bGPS_LAT_sec);
y_notsu 0:58e40a872950 106 oled1.foreground(0xffff00); //Yellow
y_notsu 0:58e40a872950 107 oled1.locate(0,8);
y_notsu 0:58e40a872950 108 oled1.printf("LNG =");
y_notsu 0:58e40a872950 109 oled1.printf("%c%03d:%02d:%02d", psGPSRTC_Data->cGPS_LNG,
y_notsu 0:58e40a872950 110 psGPSRTC_Data->bGPS_LNG_deg, psGPSRTC_Data->bGPS_LNG_min, psGPSRTC_Data->bGPS_LNG_sec);
y_notsu 0:58e40a872950 111 oled1.locate(0,9);
y_notsu 0:58e40a872950 112 oled1.printf("Qual=");
y_notsu 0:58e40a872950 113 oled1.printf("%c ", psGPSRTC_Data->cGPS_Quality);
y_notsu 0:58e40a872950 114 oled1.locate(0,10);
y_notsu 0:58e40a872950 115 oled1.foreground(0x00ffff); //Cyan
y_notsu 0:58e40a872950 116 oled1.printf("Sat =");
y_notsu 0:58e40a872950 117 oled1.printf("%3d ", psGPSRTC_Data->bGPS_Sat);
y_notsu 0:58e40a872950 118 oled1.locate(0,11);
y_notsu 0:58e40a872950 119 oled1.printf("HDOP=");
y_notsu 0:58e40a872950 120 oled1.printf("%1d.%1d ", psGPSRTC_Data-> bGPS_HDOP_I, psGPSRTC_Data->bGPS_HDOP_D);
y_notsu 0:58e40a872950 121 oled1.locate(0,12);
y_notsu 0:58e40a872950 122 oled1.printf("ASL =");
y_notsu 0:58e40a872950 123 oled1.printf("%4dm", psGPSRTC_Data->wGPS_ASL_m);
y_notsu 0:58e40a872950 124 oled1.locate(0,13);
y_notsu 0:58e40a872950 125 oled1.printf("GEO =");
y_notsu 0:58e40a872950 126 oled1.printf("%4dm", psGPSRTC_Data->wGPS_GEO_m);
y_notsu 0:58e40a872950 127 wait(0.3);
y_notsu 0:58e40a872950 128
y_notsu 0:58e40a872950 129 }
y_notsu 0:58e40a872950 130
y_notsu 0:58e40a872950 131
y_notsu 0:58e40a872950 132 }
y_notsu 0:58e40a872950 133
y_notsu 0:58e40a872950 134 void oled_image2(const unsigned int *ptr2)
y_notsu 0:58e40a872950 135 {
y_notsu 0:58e40a872950 136 short height,width;
y_notsu 0:58e40a872950 137 int colour;
y_notsu 0:58e40a872950 138 height = *ptr2;
y_notsu 0:58e40a872950 139 ptr2++;
y_notsu 0:58e40a872950 140 width = *ptr2;
y_notsu 0:58e40a872950 141 ptr2++;
y_notsu 0:58e40a872950 142 oled1.locate(0,0);
y_notsu 0:58e40a872950 143 for(int i=1;i<=width;i++)
y_notsu 0:58e40a872950 144 {
y_notsu 0:58e40a872950 145 for(int j=1;j<=height;j++)
y_notsu 0:58e40a872950 146 {
y_notsu 0:58e40a872950 147 colour = (((*ptr2&0xF800)<<8) | ((*ptr2&0x07E0)<<5) | ((*ptr2&0x001F)<<3));
y_notsu 0:58e40a872950 148 oled1.pixel(j,i,colour);
y_notsu 0:58e40a872950 149 ptr2++;
y_notsu 0:58e40a872950 150 }
y_notsu 0:58e40a872950 151 }
y_notsu 0:58e40a872950 152 }
y_notsu 0:58e40a872950 153
y_notsu 0:58e40a872950 154 /*
y_notsu 0:58e40a872950 155 * history:
y_notsu 0:58e40a872950 156 * 0.5 (2011-Apr-07) : initial published version
y_notsu 0:58e40a872950 157 * 0.51 (2011-Apr-08) : minor modification to make the source more consistent (use " MARMEX_OB_oled::HEIGHT" instead of 128)
y_notsu 0:58e40a872950 158 */