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.
Diff: main.cpp
- Revision:
- 1:a060fd2ee1aa
- Parent:
- 0:3f8e97e08238
--- a/main.cpp Sun Feb 02 03:24:55 2014 +0000
+++ b/main.cpp Sun Feb 02 06:06:32 2014 +0000
@@ -63,19 +63,29 @@
wait_us(10); // us
while (1) {
- new_vol = pin_VR.read_u16() >> 6;
- new_vol = new_vol | 0x3f; // 6bit
+ new_vol = pin_VR.read_u16() >> 6; // 10bit (0-1023)
+
+ if (cur_vol <= new_vol - 8) {
+ new_vol = (new_vol - 8) | 0x3f; // 6bit
+
+ } else
+ if (new_vol + 8 <= (cur_vol - 0x40)) {
+ new_vol = (new_vol + 8) | 0x3f; // 6bit
+
+ } else {
+ new_vol = cur_vol;
+ }
if (new_vol != cur_vol) {
cur_vol = new_vol;
send_cmd(
- (0 << 11) // MODE0
+ (0 << 11) // MODE0
| (1 << 10) // LDL
| new_vol); // 10bit
send_cmd(
- (1 << 11) // MODE1
+ (1 << 11) // MODE1
| (1 << 10) // LDR
| new_vol); // 10bit
}