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 7:7b225c565fe6, committed 2020-02-24
- Comitter:
- bvirk
- Date:
- Mon Feb 24 14:34:14 2020 +0000
- Parent:
- 6:c69f08f464b5
- Child:
- 8:5972683a7190
- Commit message:
- ref to github in readme
Changed in this revision
--- a/Display.cpp Sun Feb 23 01:57:35 2020 +0000
+++ b/Display.cpp Mon Feb 24 14:34:14 2020 +0000
@@ -2,11 +2,11 @@
#include "Display.h"
Display::Display(MicroBitDisplay & uDpl) : uDisplay(uDpl) {
- for (uint8_t i = 0 ; i < 25; i++)
- stick[i]=false;
+ clearStick();
}
-void Display::setPixel(uint8_t x,uint8_t y) {
- uDisplay.image.setPixelValue(x,y,1);
+void Display::clear() {
+ uDisplay.image.clear();
+ clearStick();
}
void Display::setStick(uint8_t length) {
@@ -70,6 +70,11 @@
}
}
+void Display::clearStick() {
+ for (uint8_t i = 0 ; i < 25; i++)
+ stick[i]=false;
+}
+
bool Display::orPoint(uint8_t stickPos) {
return showbit == stickPos ? 1 : stick[stickPos];
}
--- a/Display.h Sun Feb 23 01:57:35 2020 +0000
+++ b/Display.h Mon Feb 24 14:34:14 2020 +0000
@@ -47,7 +47,9 @@
* @param x left 0 indexed position
* @param y top 0 indexed position
*/
- void setPixel(uint8_t x,uint8_t y);
+ //void setPixel(uint8_t x,uint8_t y);
+
+ void clear();
/**
* the stick is a binary representaion of the led display
@@ -121,6 +123,7 @@
private:
void paintStick(bool(Display::*getState)(uint8_t));
+ void clearStick();
bool bitplot(uint8_t num);
bool simplePlot(uint8_t num);
bool lessCurLength(uint8_t num);
--- a/doc/microbitOLED.md Sun Feb 23 01:57:35 2020 +0000 +++ b/doc/microbitOLED.md Mon Feb 24 14:34:14 2020 +0000 @@ -1,31 +1,4 @@ -### History of micro:bit learning a simple minded man internet of things - -1. [makecode.com](https://www.microbit.org/code) - 1. blocks programming - 2. typescript (named javascript) programming as a between layer - 3. integration with github and sharing using links. - 4. following links to [lancaster univercity](https://lancaster-university.github.io/microbit-docs/) and discrovery of equality of interface with typescript -2. [mbed.com](https://www.mbed.com/en/) - 1. struggling with finding needed component and cross searching inside for being clever - 2. Finding out that class Microbit is a final layer upon DAL and HAL - 2. Poject OLED - [code snippets](https://github.com/Tinkertanker/pxt-oled-ssd1306) borrowed - -### OLED display, 128x64 pixels, ssd1306 compatible - -... is about investigation and debug alternatives - in absense of other communications (seriel usb, bluetooth) +pesentation on Github -- Displaying at OLED display -- Having displaying in 25 led's display as a debugging alternative -- Making code framents to investigate microbit soft- and harware - -#### 25 led's display - class Display - -Types of display - -1. a stick -2. numbers in binary - 1. on each row - 1. binary - 2. decimal coded binary - 2. binary 25 led's as a whole -3. flags + https://github.com/bvirk/myMicrobit/blob/master/mbed/microbitOLED.md +
--- a/exampleBasic.cpp Sun Feb 23 01:57:35 2020 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-#include "MicroBit.h"
-#include "MicroBitI2C.h"
-#include "MicroBitPin.h"
-#include "MicroBitDisplay.h"
-
-#include "OLED.h"
-#include "Display.h"
-
-
-
-//Uncomment the one '#define example...' in file which main() shall have affect!
-//#define exampleBasic
-
-#ifdef exampleBasic
-
-MicroBit uBit;
-OLED oled;
-
-
-
-int main() {
-
- uBit.init();
- oled.init();
-
- Display display(uBit.display);
-
- oled.writeln("Hello World.");
- return 0;
-}
-
-#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example_flag.cpp Mon Feb 24 14:34:14 2020 +0000
@@ -0,0 +1,46 @@
+#include "MicroBit.h"
+
+#include "Display.h"
+#include "common.h"
+
+int8_t column=0;
+
+int8_t pixels[] =
+ {4,8,10,12,16,0,4,9,14,19,24,2,7,8,25,0,6,7,8,9,10,12,14,18,-1};
+
+
+int8_t yield() {
+ int8_t retval = pixels[column++];
+ if (retval == -1) {
+ column=0;
+ return -1;
+ }
+ return retval-1;
+ }
+
+
+void flag1(int8_t(*yieldF)()) {
+ for (int8_t i=0; i < 5; i++) {
+ display.setFlag(6*i);
+ display.setFlag(4+4*i);
+ }
+ }
+
+void flag2(int8_t(*yieldF)()) {
+ int8_t p;
+ while ((p = (yieldF)())!=-1) {
+ display.setFlag(p);
+ }
+ }
+
+void (*flg[])(int8_t(*yieldF)()) = {flag1,flag2};
+
+void example_flag() {
+ int8_t i=0;
+ while (true) {
+ display.clear();
+ (flg[i>0 ? 1 : 0])(yield);
+ i=(i+1) & 3;
+ uBit.sleep(2000);
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example_peek.cpp Mon Feb 24 14:34:14 2020 +0000
@@ -0,0 +1,88 @@
+#include "MicroBit.h"
+#include "MicroBitPin.h"
+#include "cppNorm.h"
+#include "common.h"
+
+
+/**
+ * conclusion: items incl char and char[] are on stack 4 byte alligned (0,4,8,c)
+ * on global data char isn't aligned.
+ * int8_t[] seems to 2 aligned, but it would demand a clean global date area to find out
+ * variables are not source code ordered!
+ */
+void typeSizeAndAlignment() {
+#define outputscreeen1
+#ifdef outputscreeen1
+ double d1;
+ int8_t int8[3];
+ int16_t int16;
+ int32_t int32;
+ int32_t i32;
+ // ADRESS bytes in decimal
+ //
+ void *addresses[] = {
+ int8 // b8 4
+ ,&int8[3] // bb 3
+ ,&int16 // bc 4
+ ,&d1 // c0 8
+ ,&int32 // c8 4
+ ,&i32}; // cc
+ char names[][8] = {
+ "int8"
+ ,"int8[3]"
+ ,"int16"
+ ,"d1"
+ ,"int32"
+ ,"i32"
+ };
+#else
+ int i;
+ float f;
+ char ch1;
+ char chre[9];
+ char chr3[3];
+ char chr4[4];
+ char chr2[2];
+ // ADRESS bytes(decimal)
+ void *addresses[] = {
+ chre // ac 12
+ ,&i // b8 4
+ ,&f // bc 4
+ ,&ch1 // c0 4
+ ,chr3 // c4 4
+ ,chr4 // c8 4
+ ,chr2 }; // cc
+ char names[][8] = {
+ "chre[9]"
+ ,"i"
+ ,"f"
+ ,"ch1"
+ ,"chr3[3]"
+ ,"chr4[4]"
+ ,"chr2[2]"
+ };
+
+#endif
+
+ for (int i=0; i < sizeof(addresses)/4; i++)
+ oled.printf("%-8s %p\n",names[i],addresses[i]);
+}
+struct {
+ const static int isConstStatic=0;
+ } HasConstStatic;
+
+const static int csint=0;
+
+void isGlobalConstStaticFlashed() {
+ oled.printf("const static \naddr:%p\n",&csint);
+ oled.printf("addr:%p\n",&HasConstStatic.isConstStatic);
+}
+
+void example_peek() {
+ oled.init();
+ //typeSizeAndAlignment();
+ isGlobalConstStaticFlashed();
+ release_fiber();
+}
+
+
--- a/main.cpp Sun Feb 23 01:57:35 2020 +0000
+++ b/main.cpp Mon Feb 24 14:34:14 2020 +0000
@@ -14,6 +14,8 @@
void example_clock();
void example_secClock();
void example_assert();
+void example_flag();
+void example_peek();
struct {
@@ -26,20 +28,24 @@
,{example_clock,"clock"} // 17:31
,{example_secClock,"sec-clock"} // 17:31:00
,{example_assert,"assertion"}
+ ,{example_flag,"flag"}
+ ,{example_peek,"peek"}
};
void showExample(string name) {
for (int8_t i = 0; i < sizeof(examples)/sizeof(examples[0]); i++)
if (name == examples[i].name)
- (examples[i].example)(); // who needs virtuel classes?
+ (examples[i].example)();
}
-
+/**
+ * In absence of terminal or bluetooth command interface, chose an example editing by hand
+ */
int main() {
uBit.init();
// change to try
- showExample("sec-clock");
+ showExample("peek");
uBit.panic(987);
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/utils.cpp Mon Feb 24 14:34:14 2020 +0000
@@ -0,0 +1,12 @@
+#include "MicroBit.h"
+#include "cppNorm.h"
+
+string trailedWith(const string src, char trailChar, int length) {
+ if (length <= src.length())
+ return src;
+ char buf[length+1];
+ memcpy(buf,src.toCharArray(),src.length());
+ memset(buf+src.length(),trailChar, length-src.length());
+ buf[length]='\0';
+ return string(buf);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utils.h Mon Feb 24 14:34:14 2020 +0000 @@ -0,0 +1,3 @@ +#include "cppNorm.h" + +string trailedWith(const string src, char trailChar, int length); \ No newline at end of file