Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:81948520c7ed, committed 2021-10-05
- Comitter:
- cdupaty
- Date:
- Tue Oct 05 15:30:40 2021 +0000
- Parent:
- 0:eb53bdf2b7eb
- Commit message:
- more comments to understand the program
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Oct 05 13:33:00 2021 +0000
+++ b/main.cpp Tue Oct 05 15:30:40 2021 +0000
@@ -1,21 +1,3 @@
-#include "mbed.h"
-
-//--------------------------------------------------------------------------
-// Animated flame for Adafruit Pro Trinket. Uses the following parts:
-// - Pro Trinket microcontroller (adafruit.com/product/2010 or 2000)
-// (#2010 = 3V/12MHz for longest battery life, but 5V/16MHz works OK)
-// - Charlieplex LED Matrix Driver (2946)
-// - Charlieplex LED Matrix (2947, 2948, 2972, 2973 or 2974)
-// - 350 mAh LiPoly battery (2750)
-// - LiPoly backpack (2124)
-// - SPDT Slide Switch (805)
-//
-// This is NOT good "learn from" code for the IS31FL3731; it is "squeeze
-// every last byte from the Pro Trinket" code. If you're starting out,
-// download the Adafruit_IS31FL3731 and Adafruit_GFX libraries, which
-// provide functions for drawing pixels, lines, etc. This sketch also
-// uses some ATmega-specific tricks and will not run as-is on other chips.
-//--------------------------------------------------------------------------
/*
Christian Dupaty 10/2021
IS31FL3731 with CHARLEPLEX LED MATRIX adaptation from Adafruit project to ARM MBEB, tested on NUCLEO L073RZ
@@ -35,8 +17,26 @@
ex: Wire.write (I2C_ADDR, cmd, s); I2C_ADDR address on 8bits, cmd pointer to data to send, s number of data
*/
+//--------------------------------------------------------------------------
+// Animated flame for Adafruit Pro Trinket. Uses the following parts:
+// - Pro Trinket microcontroller (adafruit.com/product/2010 or 2000)
+// (#2010 = 3V/12MHz for longest battery life, but 5V/16MHz works OK)
+// - Charlieplex LED Matrix Driver (2946)
+// - Charlieplex LED Matrix (2947, 2948, 2972, 2973 or 2974)
+// - 350 mAh LiPoly battery (2750)
+// - LiPoly backpack (2124)
+// - SPDT Slide Switch (805)
+//
+// This is NOT good "learn from" code for the IS31FL3731; it is "squeeze
+// every last byte from the Pro Trinket" code. If you're starting out,
+// download the Adafruit_IS31FL3731 and Adafruit_GFX libraries, which
+// provide functions for drawing pixels, lines, etc. This sketch also
+// uses some ATmega-specific tricks and will not run as-is on other chips.
+//--------------------------------------------------------------------------
+
+#include "mbed.h"
#include "data.h" // Flame animation data
-//#define debug
+//#define debug // for some printf
#define I2C_ADDR 0xE8 // I2C address of Charlieplex matrix 0x74
I2C Wire(I2C_SDA, I2C_SCL);
uint8_t page = 0; // Front/back buffer control
@@ -60,10 +60,10 @@
{
uint8_t i, p, s;
- s=0;
+ s=0; // s is a counter for I2C buffer (cmd) write method
pageSelect(0x0B); // Access to the Function Registers (page Night)
- cmd[0]=0;
- s++; // adress first internal register
+ cmd[0]=0; // adress first internal register
+ s++;
for(i=0; i<=0x0C; i++)
{
cmd[i+1]=0x00;
@@ -149,13 +149,17 @@
#endif
}
Wire.write(I2C_ADDR,cmd,s);
- wait_ms(30);
+ wait_ms(30); // can be adjuted for speed annimation
}
int main()
{
- //printf("Simulation flame with IS31FL3731\n\n");
+ #ifdef debug
+ printf("-------------------------------------------------------------\n");
+ printf("printf("Simulation flame with IS31FL3731\n\n");
+ printf("-------------------------------------------------------------\n");
+ #endif
+ // arduino like
setup();
-
- while(1) loop();;
+ while(1) loop();
}