Labview

Dependencies:   C12832_lcd LCD_fonts LM75B analogintest3 MMA7660 mbed

Fork of analogintest3 by Peter Mertens

Files at this revision

API Documentation at this revision

Comitter:
Bramvr
Date:
Tue May 19 11:20:51 2015 +0000
Parent:
0:e4782112c3fd
Commit message:
Labview

Changed in this revision

C12832_lcd.lib Show annotated file Show diff for this revision Revisions of this file
LCD_fonts.lib Show annotated file Show diff for this revision Revisions of this file
LM75B.lib Show annotated file Show diff for this revision Revisions of this file
Labbview.lib Show annotated file Show diff for this revision Revisions of this file
MMA7660.lib Show annotated file Show diff for this revision Revisions of this file
graphics.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832_lcd.lib	Tue May 19 11:20:51 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreschpe/code/C12832_lcd/#c9afe58d786a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_fonts.lib	Tue May 19 11:20:51 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreschpe/code/LCD_fonts/#d0b7d7bf1f56
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LM75B.lib	Tue May 19 11:20:51 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/chris/code/LM75B/#6a70c9303bbe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Labbview.lib	Tue May 19 11:20:51 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/u0068206/code/analogintest3/#e4782112c3fd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA7660.lib	Tue May 19 11:20:51 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MMA7660/#36a163511e34
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics.h	Tue May 19 11:20:51 2015 +0000
@@ -0,0 +1,165 @@
+#ifndef graphics_H
+#define graphics_H
+#include "C12832_lcd.h" 
+
+// graphics for the Christmas Demo
+//
+// Copyright (c) 2012 Peter Drescher - DC2PD
+// made by hand - I have to look for a tool ;-)
+// Released under the MIT License: http://mbed.org/license/mit
+
+static char Tree[] = {
+ 0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xfd,0xff,0xfe,0xff
+,0xff,0xfd,0xff,0xfe,0xff
+,0xf0,0x0c,0x38,0x70,0xff
+,0xf6,0x4d,0x93,0x26,0xff
+,0xf6,0x6d,0xd0,0x2e,0xff
+,0xf6,0x6d,0x93,0xee,0xff
+,0xf6,0x6c,0x30,0x60,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+,0xff,0xff,0xff,0xff,0xff
+};
+
+Bitmap bitmTree = {
+  36, // XSize
+  28, // YSize
+  5, // Bytes in Line
+  Tree,  // Pointer to picture data 
+};
+
+
+static char Santa1[] = {
+  0x07, 0x00, 0x00, // XXXXX___, XXXXXXXX, X
+  0x05, 0x00, 0x00, // XXXXX_X_, XXXXXXXX, X
+  0x07, 0x00, 0x00, // XXXXX___, XXXXXXXX, X
+  0x07, 0xC0, 0x00, // XXXXX___, __XXXXXX, X
+  0x07, 0xE0, 0x00, // XXXXX___, ___XXXXX, X
+  0x07, 0xF0, 0x00, // XXXXX___, ____XXXX, X
+  0x0F, 0xF8, 0x00, // XXXX____, _____XXX, X
+  0x1c, 0x08, 0x00, // XXX___XX, XXXX_XXX, X
+  0x08, 0xA8, 0x00, // XXXX_XXX, _X_X_XXX, X
+  0x0C, 0x08, 0x00, // XXXX__XX, XXXX_XXX, X
+  0x06, 0x28, 0x00, // XXXXX__X, XX_X_XXX, X
+  0x03, 0x98, 0x00, // XXXXXX__, _XX__XXX, X
+  0x0d, 0xfe, 0x00, // XXXX__X_, _______X, X
+  0x78, 0xf3, 0x00, // X____XXX, ____XX__, X
+  0x50, 0x61, 0x80, // X_X_XXXX, X__XXXX_, _
+  0xd0, 0x60, 0x80, // __X_XXXX, X__XXXXX, _
+  0x90, 0x00, 0x80, // _XX_XXXX, XXXXXXXX, _
+  0x90, 0x01, 0x00, // _XX_XXXX, XXXXXXX_, X
+  0x90, 0x01, 0x00, // _XX_XXXX, XXXXXXX_, X
+  0xd0, 0x03, 0x00, // __X_XXXX, XXXXXX__, X
+  0x70, 0x02, 0x00, // X___XXXX, XXXXXX_X, X
+  0x1f, 0xfc, 0x00, // XXX_____, ______XX, X
+  0x07, 0xfc, 0x00, // XXXXX___, ______XX, X
+  0x07, 0x0c, 0x00, // XXXXX___, XXXX__XX, X
+  0x07, 0x0c, 0x00, // XXXXX___, XXXX__XX, X
+  0x07, 0xbc, 0x00, // XXXXX___, _X____XX, X
+  0x03, 0x38, 0x00, // XXXXXX__, XX___XXX, X
+  0x00, 0x20, 0x00, // XXXXXXXX, XX_XXXXX, X
+};
+
+Bitmap bitmSan1 = {
+  17, // XSize
+  28, // YSize 
+  3,  // Bytes in Line
+  Santa1 ,  // Pointer to picture data 
+};
+
+
+static char Santa2[] = {
+  0x03, 0x80, 0x00 , // XXXXXX__, _XXXXXXX, X
+  0x02, 0x80, 0x00 , // XXXXXX_X, _XXXXXXX, X
+  0x07, 0x00, 0x00 , // XXXXX___, XXXXXXXX, X
+  0x07, 0xc0, 0x00 , // XXXXX___, __XXXXXX, X
+  0x07, 0xe0, 0x00 , // XXXXX___, ___XXXXX, X
+  0x07, 0xf0, 0x00 , // XXXXX___, ____XXXX, X
+  0x0f, 0xf8, 0x00 , // XXXX____, _____XXX, X
+  0x1c, 0x08, 0x00 , // XXX___XX, XXXX_XXX, X
+  0x08, 0xa8, 0x00 , // XXXX_XXX, _X_X_XXX, X
+  0x0c, 0x08, 0x00 , // XXXX__XX, XXXX_XXX, X
+  0x06, 0x28, 0x00 , // XXXXX__X, XX_X_XXX, X
+  0x03, 0x98, 0x00 , // XXXXXX__, _XX__XXX, X
+  0x0d, 0xf6, 0x00 , // XXXX__X_, ____X__X, X
+  0x78, 0xf3, 0x00 , // X____XXX, ____XX__, X
+  0x50, 0x61, 0x80 , // X_X_XXXX, X__XXXX_, _
+  0xd0, 0x60, 0x80 , // __X_XXXX, X__XXXXX, _
+  0x90, 0x00, 0x80 , // _XX_XXXX, XXXXXXXX, _
+  0x90, 0x01, 0x00 , // _XX_XXXX, XXXXXXX_, X
+  0x90, 0x01, 0x00 , // _XX_XXXX, XXXXXXX_, X
+  0xd0, 0x03, 0x00 , // __X_XXXX, XXXXXX__, X
+  0x70, 0x02, 0x00 , // X___XXXX, XXXXXX_X, X
+  0x1f, 0xfc, 0x00 , // XXX_____, ______XX, X
+  0x07, 0xdc, 0x00 , // XXXXX___, __X___XX, X
+  0x07, 0x0e, 0x00 , // XXXXX___, XXXX___X, X
+  0x07, 0x0e, 0x00 , // XXXXX___, XXXX___X, X
+  0x0e, 0x0f, 0x80 , // XXXX___X, XXXX____, _
+  0x08, 0x00, 0x00 , // XXXX_XXX, XXXXXXXX, X
+  0x00, 0x00, 0x00 , // XXXXXXXX, XXXXXXXX, X
+};
+
+Bitmap bitmSan2 = {
+  17, // XSize
+  28, // YSize 
+  3,  // Bytes in Line
+  Santa2 ,  // Pointer to picture data 
+};
+
+
+static char Santa3[] = {
+  0x1c, 0x00, 0x00 , //XXX___XX, XXXXXXXX, X
+  0x17, 0x00, 0x00 , //XXX_X___, XXXXXXXX, X
+  0x1f, 0xc0, 0x00 , //XXX_____, __XXXXXX, X
+  0x07, 0xe0, 0x00 , //XXXXX___, ___XXXXX, X
+  0x07, 0xf0, 0x00 , //XXXXX___, ____XXXX, X
+  0x0f, 0xf8, 0x00 , //XXXX____, _____XXX, X
+  0x1c, 0x08, 0x00 , //XXX___XX, XXXX_XXX, X
+  0x08, 0xa8, 0x00 , //XXXX_XXX, _X_X_XXX, X
+  0x0c, 0x08, 0x00 , //XXXX__XX, XXXX_XXX, X
+  0x06, 0x28, 0x00 , //XXXXX__X, XX_X_XXX, X
+  0x03, 0x98, 0x00 , //XXXXXX__, _XX__XXX, X
+  0x0d, 0xf6, 0x00 , //XXXX__X_, ____X__X, X
+  0x78, 0xf3, 0x00 , //X____XXX, ____XX__, X
+  0x50, 0xe1, 0x80 , //X_X_XXXX, ___XXXX_, _ 
+  0xd0, 0x60, 0x80 , //__X_XXXX, X__XXXXX, _
+  0x90, 0x00, 0x80 , //_XX_XXXX, XXXXXXXX, _
+  0x90, 0x01, 0x00 , //_XX_XXXX, XXXXXXX_, X
+  0x90, 0x01, 0x00 , //_XX_XXXX, XXXXXXX_, X
+  0x20, 0x03, 0x00 , //__X_XXXX, XXXXXX__, X
+  0x70, 0x02, 0x00 , //X___XXXX, XXXXXX_X, X
+  0x1f, 0xfc, 0x00 , //XXX_____, ______XX, X
+  0x07, 0xdc, 0x00 , //XXXXX___, __X___XX, X
+  0x07, 0x0e, 0x00 , //XXXXX___, XXXX___X, X
+  0x07, 0x0e, 0x00 , //XXXXX___, XXXX___X, X
+  0x07, 0xcf, 0x80 , //XXXXX___, __XX____, _
+  0x00, 0x00, 0x00 , //XXXXXXXX, XXXXXXXX, X
+};
+
+Bitmap bitmSan3 = {
+  17, // XSize
+  26, // YSize 
+  3,  // Bytes in Line
+  Santa3 ,  // Pointer to picture data 
+};
+
+
+#endif
\ No newline at end of file
--- a/main.cpp	Tue Apr 28 11:41:25 2015 +0000
+++ b/main.cpp	Tue May 19 11:20:51 2015 +0000
@@ -1,24 +1,99 @@
 #include "mbed.h"
 #include "SerialRPCInterface.h"
+#include "LM75B.h"
+#include "MMA7660.h"
+#include <string>
+
+#include "C12832_lcd.h"
+#include "Arial_9.h"
+#include "Small_7.h"
+#include "graphics.h"
 SerialRPCInterface SerialInterface(USBTX, USBRX);
 float ai1=0;
 float ai2=0;
 int alarm1 = 0;
 int alarm2 = 0;
+float temp = 0;
+int text;
+float period;
+int position;
+
+float X = 0;
+float Y = 0;
+float Z = 0;
+
+Serial pc(USBTX, USBRX);
 RPCVariable<float> rpc_ai1(&ai1,"ai1");
 
 RPCVariable<float> rpc_ai2(&ai2,"ai2");
  
 RPCVariable<int> rpc_alarm1(&alarm1,"alarm1");
 RPCVariable<int> rpc_alarm2(&alarm2,"alarm2");
+RPCVariable<float> rpc_temp(&temp,"temp");
+RPCVariable<int> rpc_text(&text,"text");
+RPCVariable<float> rpc_period(&period,"period");
+RPCVariable<int> rpc_position(&position,"position");
+
+RPCVariable<float> rpc_X(&X,"X");
+RPCVariable<float> rpc_Y(&Y,"Y");
+RPCVariable<float> rpc_Z(&Z,"Z");
+
 AnalogIn pot2(p19);
 DigitalOut led(LED1);
 AnalogIn pot1(p20);
 DigitalOut led2(LED2);
+LM75B tmp(p28,p27);
+C12832_LCD lcd;
+PwmOut r (p23);
+PwmOut g (p24);
+PwmOut b (p25);
+PwmOut spkr(p26);
+PwmOut servo(p21);
+MMA7660 MMA(p28, p27);
 
+
+void Welkom(void);
  
 int main() {
+    //Labview
+    Base::add_rpc_class<AnalogIn>();
+    Base::add_rpc_class<AnalogOut>();
+    Base::add_rpc_class<DigitalIn>();
+    Base::add_rpc_class<DigitalOut>();
+    Base::add_rpc_class<DigitalInOut>();
+    Base::add_rpc_class<PwmOut>();
+    Base::add_rpc_class<Timer>();
+    Base::add_rpc_class<SPI>();
+    Base::add_rpc_class<BusOut>();
+    Base::add_rpc_class<BusIn>();
+    Base::add_rpc_class<BusInOut>();
+    Base::add_rpc_class<Serial>();
+    
+    char buf[256], outbuf[256];
+    
+   
+ lcd.cls();
+    //update axis period
+    r.period(0.001); 
+    Welkom();
+    wait(2);
+    lcd.cls();
+    
     while (1){
+    
+        pc.gets(buf,256);
+        rpc(buf,outbuf);
+        pc.printf("%s\n",outbuf);
+        
+       temp = tmp.read() - 2;
+        
+        lcd.cls();
+        lcd.locate(0,15);
+        lcd.printf(" Nummer: %d",text);
+        lcd.copy_to_lcd();
+        
+        
+        
         ai1 = pot2;
         ai2 = pot1;
         if(pot2 > 0.3) {
@@ -34,6 +109,67 @@
         } else {
             led2 = 0;
             alarm2 = led2;
-        }    
+        }  
+        
+        X = MMA.x();
+        Y = MMA.y();
+        Z = MMA.z();   
+      //------------------------
+        spkr.period(period /100000);
+        spkr=0.5;
+    
+        servo.period_ms(20);
+        servo=((position) * 0.000511 + 0.026);
+        
+       
     }
+}
+
+void Welkom(void)
+{
+  int i,s;
+    lcd.cls();
+    lcd.set_font((unsigned char*) Arial_9);
+    s = 3;
+    lcd.print_bm(bitmTree,95,0);  // print chistmas tree
+    lcd.copy_to_lcd(); 
+    lcd.setmode(XOR);             // XOR - a second print will erase  
+    for(i = -15; i < 75; ){     
+        lcd.print_bm(bitmSan1,i,2);
+        wait(0.1);
+        lcd.copy_to_lcd();           // update lcd  
+        lcd.print_bm(bitmSan1,i,2);  // erase
+        i= i+s;
+        lcd.print_bm(bitmSan2,i,2);  // print next
+        wait(0.1);
+        lcd.copy_to_lcd();           // update lcd   
+        lcd.print_bm(bitmSan2,i,2);  // erase
+        i= i+s;
+        lcd.print_bm(bitmSan3,i,2);  // print next 
+        wait(0.1);
+        lcd.copy_to_lcd();           // update lcd
+        lcd.print_bm(bitmSan3,i,2);  // erase
+        i= i+s;
+   }
+   lcd.print_bm(bitmSan3,i,2);
+   lcd.set_auto_up(0);
+   for(i=-20; i<5; i++){             // scrolling text
+     lcd.locate(5,i);
+     lcd.printf("Welkom bij");
+     lcd.locate(5,i+12);
+     lcd.printf("Labview!!!");
+     lcd.copy_to_lcd();
+     lcd.locate(5,i);
+     wait(0.2);
+     lcd.printf("Welkom bij");
+     lcd.locate(5,i+12);
+     lcd.printf("Labview!!!");
+     lcd.copy_to_lcd();
+     i=i+1;
+   }  
+   lcd.locate(5,i);
+   lcd.printf("Welkom bij");
+   lcd.locate(5,i+12);
+   lcd.printf("Labview!!!");
+   lcd.copy_to_lcd();   
 }
\ No newline at end of file