Badge base program
Rsadeika
Posts: 3,837
in Propeller 1
Yes, I got sick and tired of trying to figure out if the Badge is on or off. This is my concept for a base starting program, you would burn it to the EEPROM, immediately. That way when you are just starting with some programming, at least you know if your Badge is on or off, and you have a visual for the actual battery voltage.
I use my "universal" RCT value, but you may want to use a volt meter to check what your actual voltage reading is compared to what the voltage is that is displayed.
I think that on the next Badge model, an LED should be placed below the OSH button, that way the power issue could be associated with that button.
So, the way this works, the below program would be burned to the EEPROM, then the below code could be the starting point for your next great Badge program.
Ray
I use my "universal" RCT value, but you may want to use a volt meter to check what your actual voltage reading is compared to what the voltage is that is displayed.
I think that on the next Badge model, an LED should be placed below the OSH button, that way the power issue could be associated with that button.
So, the way this works, the below program would be burned to the EEPROM, then the below code could be the starting point for your next great Badge program.
Ray
/* onoff_Base.c Jan 20, 2016 * Badge start up program in EEPROM * Turns on blue LED next to P25 * when Badge is turned on. Also * displays the battery voltage on * the bootom line of oled. * */ #include "simpletools.h" #include "badgetools.h" /* Voltage gauge*/ float calcVt(float batteryVolts, int decayMicros); float batVolts(float vt); float RC = 360000.0 * (1.0 / 100000000.0); float vt, vbat; /****************/ /* Function prototypes */ void BatUpdate(void); int main() { // Add startup code here. badge_setup(); pause(250); led(2,ON); // LED - next to P25. /* Voltage RCT value. */ vt = calcVt(4.17, 1453); // Universal RCT value. /******************/ while(1) { // Add main loop code here. BatUpdate(); pause(500); } } /******************/ /* Functions */ /* Battery voltage readout. */ void BatUpdate(void) { text_size(SMALL); cursor(0,7); // Voltage vbat = batVolts(vt); pause(100); oledprint("%1.2f V", vbat); } /* Battery voltage calculations. */ float calcVt(float voltsBattery, int microsDecay) { float voltsThreshold, tDecay; tDecay = ((float) microsDecay) / 1000000.0; voltsThreshold = voltsBattery * (1 - exp(-tDecay / RC)); return voltsThreshold; } float batVolts(float voltsThreshold) { float voltsBattery, microsDecay; low(0); pause(1); microsDecay = ((float) rc_time(0, 0)) / 1000000.0; voltsBattery = voltsThreshold / (1 - exp(-microsDecay / RC)); return voltsBattery; } /******************/
Comments
On line 1498 ofn badgetools.h
[code]typedef volatile struct screen {
volatile int cog;
volatile int command;
volatile int CS;
volatile int DC;
volatile int DATA;
volatile int CLK;
volatile int RST;
volatile int vccstate;
volatile int displayWidth;
volatile int displayHeight;
volatile int displayType;
volatile int AutoUpdate;
volatile uint8_t buffer[LCD_BUFFER_SIZE_BOTH_TYPES];
volatile int charSize;
volatile int crsrX;
volatile int crsrY;
} screen; <*****************************************************-
What version of badgetools.h are you using?
What are you using for build option, (board type, Compiler Type, Memory Model?)
I am really surprised that you got all of those errors, what is your set up?
Ray
The SimpleIDE versions, as far as I can tell, the version for Windows and Linux run the same. The version for the Raspberry Pi is quite a bit behind the others. I only use that version in a very casual circumstance, in other words, no serious programming. I was going to try putting together a Raspberry Pi Propeller HAT with some IR hardware, but since the Raspberry Pi SimpleIDE version will not work with the HAT, that experiment will be put off, for who knows how long.
So, why do I use SimpleIDE PropGCC and not Spin? As it pertains to working with the Hackable Badge, I find PropGCC to be better suited to deal with creating menus and such, for the Badge. I tried both Spin and PropGCC, PropGCC wins, hands down. I am not locked into PropGCC, but at the moment, PropGCC is much better suited to work with the Badge, for me, your mileage may vary.
Their have been some rumors floating around that PropBasic may rise from the dead, but those are only rumors. The only reason I bring this up is, I am wondering how that would be able to handle programming the Badge? If the code overhead could be lowered by using PropBasic, and you could get around the language quirkiness, that could be a reasonable choice to work with the Badge.
Well, why the Hackable Badge? Of all the boards offered by Parallax, I find the Hackable Badge to be a better bang for the buck, IMHO. And believe me, I have tried them all. Unfortunately, at the moment, there does not seem to be a whole lot of people that share my opinion. And I read somewhere, a suggestion for the use of a Raspberry Pi Zero, make a mobile Badge, WOW. I guess, it is not just Parallax, that has their eye on that area. Just wondering, if you could somehow attach one of those ESP WiFi doodads to the Hackable Badge...
Ray
Ray
The program below can probably be enhanced and expanded quite a bit, I leave that up your imagination and determination. Now, when you go to the next ActivityBot competition, you can actually time your daughter Jane's Bot entry when it does erco's figure 8 competition.
Now, if Jane has her own Badge, she could probably program the Badge to not only time the run, but maybe even start/stop the Bot with her Badge.
Ray