Final Project for ECE-4180 Fall 2022. Interface with ENS160 AQI sensor and display the readings on uLCD.
Dependencies: 4DGL-uLCD-SE ENS160_Library mbed PinDetect mbed-rtos
Revision 5:a1ef40ff0f78, committed 2013-11-20
- Comitter:
- 4180_1
- Date:
- Wed Nov 20 03:26:19 2013 +0000
- Parent:
- 4:25a266a74a4c
- Child:
- 6:f752accd632c
- Commit message:
- ver1.3
Changed in this revision
| 4DGL-uLCD-SE.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 |
--- a/4DGL-uLCD-SE.lib Mon Nov 18 03:06:14 2013 +0000 +++ b/4DGL-uLCD-SE.lib Wed Nov 20 03:26:19 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/4180_1/code/4DGL-uLCD-SE/#9ba47197d94f +http://mbed.org/users/4180_1/code/4DGL-uLCD-SE/#74df7fc26fef
--- a/main.cpp Mon Nov 18 03:06:14 2013 +0000
+++ b/main.cpp Wed Nov 20 03:26:19 2013 +0000
@@ -27,7 +27,7 @@
int main()
{
- int pixelcolors[400];
+ int pixelcolors[40][40];
// basic printf demo = 16 by 18 characters on screen
uLCD.printf("\nHello uLCD World\n"); //Default Green on black text
uLCD.printf("\n Starting Demo...");
@@ -71,13 +71,15 @@
uLCD.printf("TxtLine %2D Page %D\n",i%16,i/16 );
i++; //16 lines with 18 charaters per line
}
-//draw an image pixel by BLIT (Block Image Transfer)
+//draw an image using BLIT (Block Image Transfer) fastest way to transfer pixel data
uLCD.background_color(BLACK);
uLCD.cls();
- for(int i=0; i<400; i++) {
- pixelcolors[i] = RED;
+ for(int i=0; i<40; i++) {
+ for(int k=0; k<40; k++) {
+ pixelcolors[i][k] = RED;
+ }
}
- uLCD.BLIT(50, 50, 20, 20, &pixelcolors[0]);
+ uLCD.BLIT(50, 50, 40, 40, &pixelcolors[0][0]);
wait(5);
//draw an image pixel by pixel
uLCD.background_color(BLACK);
@@ -110,7 +112,34 @@
Z_im = 2*Z_re*Z_im + c_im;
Z_re = Z_re2 - Z_im2 + c_re;
}
- if(isInside==false) uLCD.pixel(x,y,((niterations & 0xFC0)<<14)+((niterations & 0x38)<<9)+((niterations & 0x07)<<5) );
+ if(isInside==false) uLCD.pixel(x,y,((niterations & 0xF00)<<12)+((niterations & 0xF0)<<8)+((niterations & 0x0F)<<4) );
}
}
-}
+ wait(5);
+ // PLASMA wave BLIT animation
+ uLCD.cls();
+ int num_cols=40;
+ int num_rows=40;
+ double a,b,c=0.0;
+ while(1) {
+ for (int k=0; k<num_cols; k++) {
+ b= (1+sin(3.14159*k*0.75/(num_cols-1.0)+c))*0.5;
+ for (int i=0; i<num_rows; i++) {
+ a= (1+sin(3.14159*i*0.75/(num_rows-1.0)+c))*0.5;
+ // a and b will be a sine wave output between 0 and 1
+ // sine wave was scaled for nice effect across array
+ // uses a and b to compute pixel colors based on rol and col location in array
+ // also keeps colors at the same brightness level
+ if ((a+b) <.667)
+ pixelcolors[i][k] = (255-(int(240.0*((a+b)/0.667)))<<16) | (int(240.0*((a+b)/0.667))<<8) | 0;
+ else if ((a+b)<1.333)
+ pixelcolors[i][k] = (0 <<16) | (255-(int (240.0*((a+b-0.667)/0.667)))<<8) | int(240.0*((a+b-0.667)/0.667));
+ else
+ pixelcolors[i][k] = (int(255*((a+b-1.333)/0.667))<<16) | (0<<8) | (255-(int (240.0*((a+b-1.333)/0.667))));
+ }
+ }
+ uLCD.BLIT(50, 50, 40, 40, &pixelcolors[0][0]);
+ c = c + 0.0314159*3.0;
+ if (c > 6.2831) c = 0.0;
+ }
+}
\ No newline at end of file
