cleaned up verison

Dependencies:   mbed C12832_lcd LCD_fonts NeoStrip

Files at this revision

API Documentation at this revision

Comitter:
slackerjacker
Date:
Tue Apr 20 11:02:36 2021 +0000
Parent:
1:a9f32c0c835d
Child:
3:d8620e883b77
Commit message:
Jack's code

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
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 Apr 20 11:02:36 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/dreschpe/code/C12832_lcd/#8f86576007d6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_fonts.lib	Tue Apr 20 11:02:36 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/dreschpe/code/LCD_fonts/#d0b7d7bf1f56
--- a/main.cpp	Thu Feb 04 14:03:17 2021 +0000
+++ b/main.cpp	Tue Apr 20 11:02:36 2021 +0000
@@ -8,21 +8,30 @@
 #include "mbed.h"
 #include "NeoStrip.h"
 #include "gt.h"
+#include "C12832_lcd.h"
+#include "Arial_9.h"
+#include "Small_7.h"
 
-#define N 5  //number of leds
+
+#define N 12  //number of leds
 
 
 #define PATTERNS 3
+Serial pc(USBTX, USBRX);
 
 //int hueToRGB(float h);
 //void pattern0();
-//oid pattern1();
+//void pattern1();
 //void pattern2();
 
 // array of function pointers to the various patterns
 //void (*patterns[])(void) = {&pattern0, &pattern1, &pattern2};
 
-NeoStrip strip(p25, N);
+NeoStrip strip(p25, N); // DIN PIN with number of LEDs
+NeoStrip led1(p25, 0); 
+C12832_LCD LCD("LCD");
+//NeoStrip leds[] = {(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12)};
+
 //DigitalIn b1(p20); // brightness up
 //DigitalIn b2(p19); // brightness down
 //DigitalIn b3(p22); // next pattern
@@ -40,41 +49,283 @@
 
 	//bool b3o = b3;		// old copy of button 3 to poll for changes
 	//int p = 0;
-	   
-	   
-    float bright = 0.2;	// 20% is plenty for indoor use
-    int color = 0x122446; //0xFF0000;  //red
-     
+	
+	////////////////////////////////////
+	//////note colours value below////// 
+	////////////////////////////////////
+	 
+    float bright = 0.05;	// 20% is plenty for indoor use
+    int red = 0xFF0000; 
+    int orange = 0xFF8000;
+    int yellow = 0xFFFF00;
+    int green = 0x00FF44; 
+    int blue = 0x00BFFF; 
+    int indigo = 0x0F0082;
+    int violet = 0x8000B4;
+    int white = 0xFFFFFF;
+	int i = 0; 
+	int hueToRGB(float h);
+    
 	strip.setBrightness(bright);	// set default brightness
-	
+
+
+	pc.printf("1 - Bootup\n\r");
+	pc.printf("2 - Bootdown\n\r");
+	pc.printf("3 - Clear\n\r");
+	pc.printf("4 - Happy\n\r");
+	pc.printf("5 - Sad\n\r");
+
 	while(true)
-	{
-    //strip.setPixels(0, N, test_img);
+
+	{if (pc.readable()) {
+            switch(pc.getc()) {
+                case '1'://bootup sequence
+//strip.setPixels(0, N, test_img);
+    LCD.cls();
+        {
     strip.clear();
     strip.write();
-    wait_ms(1000);
-    strip.setPixel(0,color);
+    wait_ms(200);
+    strip.setPixel(0,red);
+    strip.write();
+    wait_ms(200);
+    
+    strip.setPixel(1,orange);
     strip.write();
-    wait_ms(1000);
+    wait_ms(200);
+    
+    strip.setPixel(2,yellow);
+    strip.write();
+    wait_ms(200);
+    
+    strip.setPixel(3,green);
+    strip.write();
+    wait_ms(200);
+    
+    strip.setPixel(4,blue);
+    strip.write();
+    wait_ms(200);
     
-    strip.setPixel(1,color);
+    strip.setPixel(5,indigo);
+    strip.write();
+    wait_ms(200);
+    
+    strip.setPixel(6,violet);
+    strip.write();
+    wait_ms(200);
+    
+    strip.setPixel(7,indigo);
     strip.write();
-    wait_ms(1000);
+    wait_ms(200);
+    
+    strip.setPixel(8,blue);
+    strip.write();
+    wait_ms(200);
     
-    strip.setPixel(2,color);
+    strip.setPixel(9,green);
+    strip.write();
+    wait_ms(200);
+    
+    strip.setPixel(10,yellow);
+    strip.write();
+    wait_ms(200);
+    
+    strip.setPixel(11,orange);
     strip.write();
-    wait_ms(1000);
+    wait_ms(200);
+}   
+ 
+
+      
+                    break;
+                	case '2'://bootdown sequence
+  
+    LCD.cls();
+    
+    strip.setPixel(11,orange);
+    strip.write();
+    wait_ms(1);
+
+    
     
-    strip.setPixel(3,color);
+    strip.setPixel(10,yellow);
+    strip.write();
+    wait_ms(1);
+
+
+    strip.setPixel(9,green);
+    strip.write();
+    wait_ms(1);
+
+
+    strip.setPixel(8,blue);
+    strip.write();
+    wait_ms(1);
+
+
+    strip.setPixel(7,indigo);
     strip.write();
-    wait_ms(1000);
-    
-    strip.setPixel(4,color);
+    wait_ms(1);
+
+    strip.setPixel(6,violet);
+    strip.write();
+    wait_ms(1);
+
+    strip.setPixel(5,indigo);
+    strip.write();
+    wait_ms(1);
+
+    strip.setPixel(4,blue);
+    strip.write();
+    wait_ms(1);
+
+    strip.setPixel(3,green);
     strip.write();
-    wait_ms(1000);
-    
+    wait_ms(1);
+
+    strip.setPixel(2,yellow);
+    strip.write();
+    wait_ms(1);
+
+    strip.setPixel(1,orange);
+    strip.write();
+    wait_ms(1);
+
+    strip.setPixel(0,red);
+    strip.write();
+    wait_ms(1);
+
+{
+	for (int i = 11; i >= 0; i--)
+	{strip.setPixel(i,0,0,0);
+    strip.write();
+    wait_ms(500);
 	}
 }
+   
+    
+
+    
+
+                    break;
+                    case '3'://clear
+    LCD.cls();
+    strip.clear();
+    strip.write();
+    
+    break;
+                	case '4':
+
+    LCD.claim(stdout);     
+    LCD.locate(10,0);
+    LCD.set_font((unsigned char*) Arial_9);
+    printf("Happy Bot");
+    LCD.copy_to_lcd();
+    LCD.set_font((unsigned char*) Small_7);
+
+
+while(true)
+{	
+{	
+		for (int i = 0; i < N; i++)
+		{
+		strip.setPixel(i,white);
+	    strip.write();
+	    wait_ms(15);
+	    }
+
+//if(white)
+{	
+		for (int i = 0; i < N; i++)
+		{
+		strip.setPixel(i,yellow);
+	    strip.write();
+	    wait_ms(50);
+	    }
+//else(yellow)    
+{
+		for (int i =0; i < N; i++)
+		{
+		strip.setPixel(i,orange);
+		strip.write();
+		wait_ms(50);
+		}
+
+}
+//return 1;
+
+
+
+
+//for (int i = 0; i < 4; i++)
+//strip.clear();
+//wait_ms(100);
+
+
+         	break;
+         	
+				case '5':
+{	
+		for (int i = 0; i < 12; i++)
+		strip.setPixel(i,blue);
+	    strip.write();
+	    wait_ms(1);
+	    } 	
+	    
+{
+        for (int i = 0; i<0.2; i+0.01)
+        strip.setBrightness(bright+i);
+        wait_ms(20);
+         }
+         
+         
+         
+         	
+         	
+         	
+ 				break;        	
+         	
+         	
+       //  			case '5':
+
+{
+	static float dh = 360.0 / N;
+	static float x = 0;
+
+	for (int i = 0; i < N; i++)
+		strip.setPixel(i, hueToRGB((dh * i) - x));
+	
+	x += 1;
+	if (x > 360)
+		x = 0;
+}
+
+//			break;
+//led1 = 1;
+//wait(0.5);
+//strip.write();
+//led1 = !1;
+//wait(0.5);
+//strip.write();
+
+                	
+ //  PwmOut strip();
+  //  strip.setPixel.write(0,red,brightness));
+
+    
+
+	              
+    //    wait_ms(30);                          
+      //  brightness = brightness + fadeAmount;            
+        
+        //if((int)brightness == 1.0)           
+          //  brightness = 0;
+        //{
+                    
+                    
+    
+	
+//}
 
 
 
@@ -236,4 +487,5 @@
 
 	return (R << 16) | (G << 8) | B;
 }
-*/
+*/}}
+}}}}}