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.
Dependencies: BLE_API nRF51822 mbed
Fork of KS7 by
main.cpp
- Committer:
- akita11
- Date:
- 2015-10-22
- Revision:
- 3:2398a9368c9b
- Parent:
- 2:09bf05d66065
- Child:
- 4:edd6e262de9e
File content as of revision 3:2398a9368c9b:
#include "mbed.h"
#include "io.h"
io io;
Ticker tk; // 1s timer for switch check & weighgt measure
float weight;
uint8_t fPow = 0;
// 1s timer for switch check & weighgt measure
void ticker_1s()
{
io.analog_pow(1); // turn analog power on
weight = io.get_weight(); // get weight [g]
/*
note: this routine should be re-arranged (akita11)
// check switch, and control power flag (fPower)
if (fPow == 0 && io.get_switch() == 1){
while(io.get_switch() == 1); // wait until switch released
fPow = 1;
}
if (fPow == 1 && io.get_switch() == 1){
while(io.get_switch() == 1); // wait until switch released
fPow = 0;
}
*/
io.analog_pow(0); // turn analog power off
}
int main()
{
tk.attach(&ticker_1s, 1);
io.calibrate_weight(); // initial calibration
io.display(0.8); // display intensity 80%
while(1){
io.display_value = (uint16_t)(weight * 9999.0); // dummy display
wait(0.1);
}
}
