Building your own programmable clock

20180120_204454Wow, it’s been quite a while since the last posting.  I thought we would start the year off with a cool project, a reboot of my Half-Byte Clock, featuring Embedded Tiny Basic. This time, I use an Arduino Nano and a nice canvas/wooden ‘case’ to house it all.

Instead of using the somewhat large Half-Byte Console board, I use the Nano so it fit inside the wooden frame. The frame is roughly one inch thick, just big enough for the Nano and all of the components to fit. On this particular iteration, the light sensor and speaker are on the back of the frame and, because of poor planning, the temperature sensor sticks out of the side. I intend to remedy that, but that will be later.  I am too busy to worry about that right now.

The Components

For the project, you will need:Samsung 6980

    • Arduino Nano or similar 328 based microcontroller board
    • HC-06 Bluetooth module
    • DHT-11 Temperature sensor
    • Light Sensor (I used the OSEP LIGHT 01 module)
    • Two or Three 8×8 LED Matrix displays, assembled with controller
    • DS3231 RTC for Arduino (Real Time Clock)
    • Small speaker (I stole this out of a toy cell phone I purchased at Dollar Tree)
    • Case/Frame/Canvas

My total cost is about twenty five dollars. The most costly part was the canvas frame-$8.95 at Target. All other parts were sourced from Hobby Town or Amazon.

Features

The clock features programmability via Half-Byte Embedded BasiSamsung 6945c, though you can use whatever code you like. This project, though, is aimed at a reprogrammable device that can display the time/date, temperature/humidity, output sound, use the ambient light to brighten or darken the display and be programmable over Bluetooth.  You have about 1k of RAM to store your Basic code and, once saved, will remain in memory, even if you unplug it. Upon power up, if there is something in memory, it will auto start after five seconds.

Wiring it Up

I was going to get all fancy and draw a diagram, but I think the pin connections will make more sense to more people, so that’s what I am going to do.  There are also photos you can look at.  As my hands aren’t as steady as they once were, my soldering leaves a lot to be desired.

DHT 11:

  • Data line to pin 2 of Nano
  • (+) to +5v on NanoSamsung 7010
  • (-) to GND on Nano

 

RCT:

  • SCL to A5
  • SDA to A4
  • GND to GND
  • VCC to +5v

 

Light Sensor:

  • Pin S to A0 on NanoSamsung 7008
  • (+) to 3.3v on Nano
  • (-) To GND on Nano

 

LED Array:

  • data to pin D12    DIN pin of MAX7219 module
  • load to pin D10    CS pin of MAX7219 module
  • clk to pin D11       CLK pin of MAX7219 module

 

Speaker:

  • GND to GND
  • + to Pin D8 on NanoSamsung 7014

 

HC-06 Bluetooth:

  • VCC to +5v
  • GND to GND
  • RX to TX on Nano
  • TX to RX on Nano

Sample Embedded Basic Startup Apps:

Example 1:

100 PRINT "Welcome to Half-Byte LED Programmable Clock"
110 SCROLL " HALF-BYTE  "
111 SCROLL " Clock."
112 IF HOUR(0)<12 SCROLL " Good Morning! "
114 IF HOUR(0)>11 IF HOUR(0)<18 SCROLL " Good Afternoon! "
116 IF HOUR(0)>17 IF HOUR(0)<=23 SCROLL "  Good Evening!  "
120 TIME
125 IF IN(0)<>-1 GOTO 600
130 SCROLL ".   Temp is "
140 TEMP
145 SCROLL "F  "
150 SCROLL "Humidity is "
160 HUMID
170 SCROLL "  Hello!  "
180 IF IN(0)<>-1 GOTO 600
190 IF RND(99)>50 GOTO 110
200 SCROLL "       "
205 O=MINUTE(0)
210 W=15
220 H=7
230 X=RND(W)
240 Y=RND(H)
250 P=RND(W)
260 Q=RND(H)
265 IF IN(0)<>-1 GOTO 600
290 SET X,Y,0
300 SET 16+(X),Y,1
310 SET 16+(X),H-Y,1
320 SET 16+(W-X),Y,1
330 SET 16+(W-X),H-Y,1
340 IF IN(0)<>-1 GOTO 600
350 SET 16+(P),Q,0
360 SET 16+(P),H-Q,0
370 SET 16+(W-P),Q,0
380 SET 16+(W-P),H-Q,0
390 IF IN(0)<>-1 GOTO 600
400 K=MINUTE(0)
410 IF K-O>1 GOTO 110
590 GOTO 230
600 SCROLL "DONE  "

Example 1 will randomly display random dot pattern for about a minute. It also analyses the time and inserts ‘Morning’, ‘afternoon’ or ‘evening’ in the greeting.  If you are connected via USB or Bluetooth, you can interrupt the app by sending a character followed by the ENTER key.

EXAMPLE 2:

200 SCROLL "        "
210 W=15
220 H=7
230 X=RND(W)
240 Y=RND(H)
250 P=RND(W)
260 Q=RND(H)
300 SET 16+(X),Y,1
310 SET 16+(X),H-Y,1
320 SET 16+(W-X),Y,1
330 SET 16+(W-X),H-Y,1
340 IF IN(0)<>-1 GOTO 600
350 SET 16+(P),Q,0
360 SET 16+(P),H-Q,0
370 SET 16+(W-P),Q,0
380 SET 16+(W-P),H-Q,0
390 IF IN(0)<>-1 GOTO 600
590 GOTO 230
600 SCROLL "DONE  "

Example 2 is the kaleidoscope from Example 1

EXAMPLE 3:

100 SCROLL " Half-Byte Clock "
110 H=HOUR(0)
120 IF H<12 SCROLL " Good Morning! "
130 IF H>11 IF H<18 SCROLL " Good Afternoon! "
140 IF H>17 IF H<=23 SCROLL "  Good Evening!  "
150 TIME
160 IF IN(0)<>-1 GOTO 600
170 SCROLL " Temp is "
180 TEMP
190 SCROLL "F  "
200 SCROLL "Humidity is "
210 HUMID
215 SCROLL "%         "
220 SET 20,2,1
230 SET 23,2,1
240 SET 20,4,1
250 SET 23,4,1
260 SET 21,5,1
270 SET 22,5,1
280 FOR X=1 to 5
290 DIRECTION 2
300 SCROLL"  "
310 DIRECTION 1
320 SCROLL"  "
530 IF IN(0)<>-1 GOTO 600
540 NEXT X
580 SCROLL "       "
590 GOTO 110
600 PRINT "INTERRUPTED "

Example 3 displays the date and time as well as the humidity and temp. It also shows an animated smiley face.

EXAMPLE 4:

100 SCROLL ” Half-Byte Clock ”
110 H=HOUR(0)
120 IF H>=0 IF H<12 SCROLL ” Good Morning! ”
130 IF H>11 IF H<18 SCROLL ” Good Afternoon! ”
140 IF H>17 IF H<=23 SCROLL” Good Evening! ”
150 TIME
155 IF H=17 IF MINUTE(0)>=0 IF MINUTE<=10 SCROLL ”  TIME FOR name TO COME HOME!”: TONE 8,3000,3000
160 IF IN(0)<>-1 GOTO 600
163 SCROLL ” ”
170 SCROLL “Temp is ”
175 TEMP
177 SCROLL “F  Humidity is ”
180 HUMID
190 SCROLL “%”
200 SCROLL ”   ”
220 SET 20,2,1: SET 23,2,1
240 SET 20,4,1: SET 23,4,1
260 SET 21,5,1: SET 22,5,1
280 FOR X=1 TO 5
281 DELAY 40
290 DIRECTION 2
300 SCROLL ”  ”
310 DIRECTION 1
320 SCROLL ”  ”
530 IF IN(0)<>-1 GOTO 600
560 NEXT X
580 SCROLL ”       ”
590 GOTO 110
600 SCROLL “Interrupted!”

Example 4 is an example of an ‘alarm’. It evaluates the hour and minute and displays a custom message and then generates a tone. It also features the animated smiley.

Samsung 7025With some clever coding, you could write a game, create an interesting art display, message board and more.  There are unused pins on the Nano that you can also use to wire up something to control (like a pet watering device, lights, etc.)  All of the sensors are available in Basic or, if you choose to write your own custom code, use the pin outs above to read or write to them. You are only limited by your imagination. And, well, that tiny bit of RAM that these things have. C’mon, we went to moon on less.

Advertisements

Hello, Samsung! My new journey with Android and Samsung-the Galaxy S8

Long time readers know I am a huge Windows Mobile 10 fan. I’ve had a Windows Phone/Mobile device for nearly four years and, prior to that, I had a Windows Mobile 5 device (a Motorola Q) waaaay back in 2008. Needless to say, I like Microsoft’s mobile operating systems. I had an Android phone in 2011 and then got an iPhone 4 when Sprint started carrying them. I NEVER liked that Android phone or the OS itself. I tended to crash and always told me I had filled up its storage even when there were gigabytes left on the SD card. It was slow too, much slower than my Palm Pre, Moto Q or that iPhone. Android was terrible. I said good bye and that was that.

Well, fast forward a few years and my beloved Windows Mobile 10 is, sadly, being left behind by its own creator. It never caught on with the public or with business, even with the hooks that business wanted. Sadly, it was an iOS and Android world.

Earlier this year, I spent a ton of money on an Alcatel Idol 4s with Windows Mobile 10. It is a fantastic phone, but developed an audio issue…I couldn’t hear phone calls unless on speaker phone. Apps I was using were being abandoned. I decided I needed to byte the bullet and move on. I can still use the phone, as a desktop device due to Continuum. But, what would replace such a capable phone and OS?

I read about Samsung’s Galaxy S7. Seems like a great device. But, then I discovered the S8 was out and was even more capable. So…I got one. Discounting the awful experience I had getting the phone (T-Mobile is far worse, customer service wise, than any other carrier…but, that is another story) the transition from Win Mo 10 to Android Nougat was much easier than I had thought it would be. The first thing I did was to Microsoft my phone. I installed the Arrow launcher, install Office, install Cortana, setup OneDrive, install Bing, set Bing as my default search engine, made sure the fluffy Google crap was off or uninstalled and installed SwiftKey. I tried some of the Win Mo 10 like launchers, but, ultimately, went to Arrow and its more Androidy look. The Win Mo 10 Launchers work well, but, I decided to make Arrow my default as it is developed and supported by MS and it works very well. No crashes.

So, how do I like the S8?
Well, it is superb. Fast, shiny, feels good and looks great. It is a tad more narrow than I would prefer, but that is a small thing and easily overlooked. Battery life is decent, but I think older Alcatel Fierce XL had better battery life. The curved, infinity screen is fine, but I am not sure I like the infinity screen: I inevitably do something I didn’t want to do. I do not think the curved sides are all that useful either. I’ve not seen anything that really utilizes them.

The fit and finish is superb. This phone feels like it is expensive and looks like it as well. Of course, it is expensive, around $600 to $800 (US). I really like the hardware. It is fantastic.

What about Android?
Well, I still hate Android, just not as much. I could grow to like it. In time. Maybe.

What’s good about Android?
This is a bit hard as there are certain things I really like, but I am not sure they are actually Android or Samsung developed. For instance, I like the softkey bar. home button, task button and back button are easily accessible and get out of the way when not needed. I am not sure if this is stock Android or Samsung. It’s nice, though. I also like skinning ability, but, again, I see more Samsung than Android. I know Android can do this, just not sure how much is one or the other. Android also seems to be more stable than I recall. The notification system is fantastic, but a pain in the rear as well. I think, overall, Android has come a very long way. BUT…it is still ANDROID and not Windows Mobile and therein lies most of my problems with it.

What’s bad about Android?
It is not Windows Mobile 10. Windows Mobile 10 had its live tiles, was so much easier to navigate and Edge has turned into an excellent mobile browser. Integrated Cortana worked well. Android is none of this. ‘OK, Google’ is a joke. The deafness of the launcher screens, the navigation is not very intuitive and the overall appearance of Android-while better than in the past-still has a long way to go. Material Design seems to be missing and Google Services do not seem to be any better than those from Microsoft or–gasp–Apple. Except for one big exception.

So, what’s the exception?
Google Photos is top notch. I really like this service. To steal a saying from Apple…it just works. It works when I do not ask it to do so. And, the results are very impressive. I thought Microsoft Photos, with the new video storyteller, was going to be best in class. I was wrong. Microsoft’s new Photo additions are great, but this service is even better. Try it. You. Will. LOVE IT.

So, I am out of the Windows Mobile ecosystem, probably for good. I don’t know how long I will be an Android user, but, if things continue the way they are, I don’t see myself going anywhere else for a very long time.

Embedded Tiny Basic: build apps for your projects

Embedded Tiny Basic: build apps for your projects

I, recently, embarked on building a useful if not glitzy digital clock. My first idea involved something retro: using four, seven segment, LED’s to look like something from the late 1970’s.  At the same time, I was also playing around with 8×8 LED Arrays, using the MAX7219 chip.  While playing with that, I connected one of my 1307 RTC’s to the array and loaded up a sketch to show the date and time on the arrays.  Then, it hit me…this is a much cooler clock and I can do more with it.

So, I built a prototype using one of my Half-Byte Console boards, minus the video, audio and Nunchucky connector.  Hardware wise, it was really simple…connect the arrays to pins 10, 11 and 12, the RTC to A4 and A5 and, for extra coolness, a BMP180 temp and humidity sensor to the sca and scl on the RTC.  Viola! modify the code to handle the BMP180 and Presto! A cool clock.

wp_20170121_01_55_22_pro

Prototype clock for developing Embedded Tiny Basic

I decided to build a second one to take to work.  I thought it might be useful to be able to throw up a custom message to scroll for when, say, I was in a meeting. The more I thought, the more I was convinced this thing needed some kind of control program that would be easily modified from, say, a smartphone and Bluetooth.

Well, I already had the genesis of that control program: Half Byte Tiny Basic.

So, I looked at the source and made a copy.  I then went in and removed stuff I would not need, like all of the graphics statements and functions. I removed the TVOut library, and  all of the video handling code. And TONE.  I miss TONE.

I did not need the Nunchuck code, so it was gone as well.  What was left was a nice, small shell of my control program.  I added the libraries for the 8×8 LED Array (MAXMATRIX) and added statements to manipulate the arrays: SCROLL to display text, SET to turn on or off individual LEDs, and DIRECTION to tell the arrays  which way to scroll the text.  I already had code to handle the DHT-11 temperature sensor, so I left that in (and decided to use it instead of the BMP180) and added T

wp_20170122_21_13_11_pro

Random dots on the clock

EMP and HUMID to scroll those values across the arrays, and added code for the RTC.I was going to add a mechanism that would interrupt the running program if a signal from the serial device was detected, but, there was already one there…the IN(0) function. So I left it. I now had a decent little programming language for the clock.  With HB Tiny Basic’s ability to autorun whatever is in the EEPROM, if it lost power, th

wp_20170119_15_23_11_pro

Clock, in action

e clock would just start running on its own. Sweet!

 

The HC-06 Bluetooth module works very nicely. It connects to the serial pins and communicates as if the device were connected directly to the controlling device-a PC or smartphone.  Everything fits nicely into these cheap pencil boxes I picked up from Wal-Mart for a buck each. They are just big enough for the HB Console board and are wide enough for the LED Arrays.  They don’t look all that impressive, until you power up the clock…the bright LED’s shine through the translucent plastic nicely.

Embedded Tiny Basic is useful for giving some level of intelligence to other wise dumb devices.  While you only have about 1K of RAM to use for Embedded Tiny Basic, I think that will be adequate for most things.  There is, currently, no motor control, but it could be quickly and easily added.  The functionality that is there is probably going to be good for quite a few projects.  If not, it can be modified quickly.  I am already seeing where it can be modified, even for just this particular project.  I have a few others in mind, so stayed tuned for those.

In the mean time, below is a list of the additions and a release date for the language is forthcoming.  I need to clean up the code-a bunch-before releasing it and, as well, making sure I have all you will need in order to compile and use Embedded Tiny Basic.

 New statements and function:
  • SETTIME hours,minutes,seconds,day,month,year
    • sets the time and date for the RTC
  • SET col,row,on or off
    • Turn on or off the LED at column, row
  • X=HOUR(0)
    • Get the current hour
  • X=MINUTE(0)
    • Get the current minute
  • X=MONTH(0)
    • Get the current month
  • X=DAY(0)
    • Get the current day
  • SCROLL var or “text”
    • Scrolls whatever is in the quotes
    • If there are no quoted strings, a variable value or number is displayed
  • DIRECTION 1-4 (1 is left, 2 is right, 3 is up and 4 is down)
    • Specifies the direction of the scrolling text, 1 is the default.
  • TIME (sends the date and time to the LED array)
    • Scrolls the current date and time
  • HUMID (sends humidity to LED array)
    • Scrolls the current humidity
  • Temp (sends the temp to LED array)
    • Scrolls the current temperature
  • X=TEMP(0 or 1)
    • Get the current temperature and put it in variable 'x'
    • A zero means use Celsius, a one means Farenheit
  • X=HUMID(0)
    • Returns the humidity to the variable 'x'

Below is the listing for the current “HELLO” app:

100 PRINT “Welcome to Half-Byte LED Programmable Clock”
110 SCROLL ” HALF-”
111 SCROLL “BYTE Clock…..”
112 IF HOUR(0)<12 SCROLL ” Good Morning! ”
114 IF HOUR(0)>11 IF HOUR(0)<18 SCROLL ” Good Afternoon! ”
116 IF HOUR(0)>17 IF HOUR(0)<=23 SCROLL ”  Good Evening!  ”
120 TIME
125 IF IN(0)<>-1 GOTO 600
130 SCROLL “.   Temp is ”
140 TEMP
145 SCROLL “F  ”
150 SCROLL “Humidity is ”
155 SCROLL “%”
160 HUMID
170 SCROLL ”  Hello!  ”
180 IF IN(0)<>-1 GOTO 600
190 IF RND(99)>50 GOTO 110
200 SCROLL ”       ”
205 O=MINUTE(0)
210 W=15
220 H=7
230 X=RND(W)
240 Y=RND(H)
250 P=RND(W)
260 Q=RND(H)
265 IF IN(0)<>-1 GOTO 600
300 SET 16+(X),Y,1
310 SET 16+(X),H-Y,1
320 SET 16+(W-X),Y,1
330 SET 16+(W-X),H-Y,1
340 IF IN(0)<>-1 GOTO 600
350 SET 16+(P),Q,0
360 SET 16+(P),H-Q,0
370 SET 16+(W-P),Q,0
380 SET 16+(W-P),H-Q,0
390 IF IN(0)<>-1 GOTO 600
400 K=MINUTE(0)
410 IF K-O>1 GOTO 110
590 GOTO 230
600 SCROLL “DONE  “

A note about how the arrays are referenced, using SET.  Embedded Tiny Basic is setup to handle up to four arrays. My clock only uses two, but Basic does not know this, so individual LED addressing has to be offset by 16.  Normally, with four arrays, the upper left LED would be 0,0. In my clock, it would be 16,0 since I am only using the RIGHT MOST TWO arrays, each are 8 across and 8 down.

Some other things to note from the listing above…the line IF IN(0)<>-1 GOTO 600 that is sprinkled through out the program will poll the serial port to see if there is a key press. If there is a keypress, we want to stop execution and goto line 600.  In this case, it just says ‘Done’ and stops. Lines 205, 400 and 410 make up a timer. Lines 200 through 590 just displays a random dot pattern, as a distraction.  We don’t want this all day, so we only let it run for about a minute.  Line 205 records the minute it started and line 400 gets the minute after each pattern is displayed.  Line 410 evaluates the elapsed time by subtracting the start time from the end time. If the result is greater than a one, it goes back to the clock routine.  Otherwise, it displays a new pattern. Lines 112 through 116 determines if it is morning, afternoon or evening.

The Scroll statement is lacking and somewhat buggy. I am working on fixing it, and adding more functionality to it, to make it more versatile, like PRINT currently is. I also want to add a mechanism to the language to allow it to receive messages, via Bluetooth, from, say, a smartphone.  Limited gameplay may also show up in a future release.

Embedded Tiny Basic will be released soon.

Alcatel’s Idol 4s With Windows 10 Mobile

WP_20170103_21_30_52_Pro (2)Ever since I saw the announcement for the Alcatel Idol 4s With Windows 10 Mobile, I’ve wanted that phone.  Well, it is out and I finally bought it.  Why? Well, many reasons, biggest being its ability to support Continuum and its price: $469 from T-Mobile, in the United States.

The current package also includes Alcatel’s VR headset and the phone comes with a smattering of impressive imagery and a couple of VR games, both of which seem more like tech demos than actual games.

The phone is gorgeous, one of the prettiest phones I’ve ever seen, on par with the Apple iPhone 4, which I previously regarded as the best LOOKING piece of hardware.  The Idol 4s looks better.  It’s glass back, metallic rim and a screen that, for now, never WP_20170103_21_31_23_Pro (2)seems to get finger prints. It is just the right weight and the screen is amazing.

The phone sports a Snapdragon 820 CPU, which is a quad core processor running at 2.15ghz.  It has 4gb of RAM and 64gb of storage, expandable with an SD card.  It also features a 21megapixel back camera and an 8 megapixel forward camera.  The camera can be started via a hardware button on the side of the device, a convenient if annoying feature.

The phone ships with a release of Windows 10 Mobile that was a bit behind. It immediately wanted to update to, I think, the ‘anniversary update’ rollup.  Fortunately, it went off without a problem.

The camera, which I had read was a weak point, is actually pretty decent.  In lower light, the colors are a bit washed out, just like the Alcatel Fierce XL I have, but the resolution is excellent and the images still look really nice.  I have not yet tried outdoors at night, but will do so soon.

Perhaps the best thing about the phone…and Windows 10…is the ability to use the device as a deWP_20170103_20_06_00_Prosktop or laptop computer.  That is where this device really shines.  While I had to purchase a USB C to HDMI converter, the converter works great and also sports a spare USB 3.0 connector (for a keyboard or mouse) and a USB C female connector for charging the device while connected.  The HDMI port is 4k capable and is full size, so you don’t need any funky sized connector or adaptor. The particular hub I purchased was from Mokin and sold via Amazon. I paid $23 for the device.

Connecting the phone to the Mokin switched it to Continuum and presented the desktop, as you would expect from a desktop PC.  The phone screen turns into a mouse, though using this instead of an actual mouse can be frustrating as there is no obvious way to ‘click and hold’ to drag things. At least, I have not figured that out yet. A bluetooth keyboard was paired to the deviwp_ss_20170103_0001ce and, bam! There I was, using my phone as a desktop.

Continuum, admittedly, is not perfect. For example, nothing I had on the SD card would work. For whatever the reason, Microsoft is not allowing applications on the SD card to run in Continuum. Also, not every application is Continuum compatible either.  And, protected content will not work in this mode.

Overall, however, Continuum seems, to me, to be the killer feature (until MS introduces x86 emulation to the Snapdragon) for Windows Mobile 10.  I can see carrying just the phone and adapter.  Most places one would need a computer will, very likely, have an HDMI monitor along with keyboard and mouse. Or, you can take the travel size keyboard/mouse.  I can forsee this more than taking my old laptop or even a tablet, though, admittedly, tablets can be just as productive.

61tocr  emL._SL1500_While running Continuum, I was able to run Word, Excel, OneNote, Facebook and take a call…at the same time.  The phone showed no perceptible slowdown at all.

The VR gimmick is just that, a gimmick and really not a reason to buy this phone.  That said, and taking into account the limitation of the screen, it is still rather impressive, at first.  The screen is HD, 1080p.  That’s a problem only because the screen gets split in two to present the left and right images.  This makes things a bit fuzzy and pixelated. However, it is not so bad as to make the experience a poor one.  Quite the contrary, it works well.  Too well, I got a headache and was a bit nauseated by it because my brain knew I was not really experiencing anything, though my eyes said otherwise.

Overall, the Alcatel Idol 4s with Windows 10 Mobile is an excellent, premium phone at a great price…half what most others would cost.  It looks great, works well and is fast.  Windows 10 Mobile needs a little work, but it is, overall, a great operating system and works very well. Don’t let the notion of a poor ‘store’ steer you away. The app system on all of the mobile devices is bad, I don’t care if there aren’t five hundred fart apps.  I don’t even care that there is no Youtube app, the web site works and there are a few third party apps that fill in for what is missing.

I think you’d be satisfied with this phone. I sure am.

Falling like a rock: Pebble is no more

wp_20150708_22_15_12_proA few short years ago, a product came on the market that I got excited about. The product utilized ePaper, could go a week between charges and was programmable. Better yet, it was ‘crowd funded.’  The product took off, initially, and raised a lot of money from Kickstarter.  That product, the Pebble Smartwatch, was a successful kickstarter project, probably the most successful of any from that site.

Last year, I finally got one.  I like it a lot.  The problem, though, was my smartphone. I use a Windows Mobile 10 device and there is no official app from Pebble. Eventually, someone developed a nice Pebble watch app for my favorite smartphone operating system.  For the last few months, I’ve been very happy with this setup: I see my notifications, calls, email, etc. on my watch, I don’t need to pull the phone out.  Great.

The app even works with some of the back end plumbing from Pebble.  Nice. I get weather and some other things. Very cool.

Last week (December of 2016) I see a rumor that Fitbit was purchasing Pebble.  I think, GREAT! My favorite smartwatch will get a much needed boost from an established company, that is also Windows Mobile friendly. Awesome. I may even get the new Pebble 2!  How sweet is that?

Turns out, it is bitter.

Fitbit did, in fact, buy Pebble. BUT…they only bought the services and software, NOT the hardware. So, Pebble is now history.  There is no word on when the services will cease. The watch will still work with phones, but the stuff that made it special, the heart of Pebble, will be pebble-geek-watchfaces_2-300x300going away.

No more new watches.  Fitbit did not want the hardware. Nor did they want about sixty percent of the employees either.

I now have one more piece of hardware that is orphaned.  Man, my ability to choose platforms is horrible.

Zune, Windows Phone/Mobile, Palm OS, webOS for Palm, Vista, Windows 8, CED Video Disc, LaserDisk, HD-DVD, Pontiac…and, now…Pebble.  Wow.  What a record, huh?

So, RIP, Pebble. It was nice while it lasted.

A Programming Language for a Portable Development System

Prototyping with Arduino and compatibles is fairly easy, especially when it comes to the hardware.  A breadboard simplifies things quite a bit.  A few months ago, I realized that I did not have any, so I purchased one, in a kit, on Amazon from a company called Elagoo. The kit, for about sixteen dollars (US) contained a lot of parts and the breadboard. Well, the board is fairly small, so I decided to create a portable workspace and mount the breadboard, an Arduino UNO R3 clone, a 2 x 16 LCD and some cord organizers.  It works great, and I can take my project around. Nice.  Problem, though, is that I still need to be tethered to the computer in order to write code.

WP_20161001_18_38_08_Pro_LI (2)This got me thinking…could I come up with a small but easy to use interface language that could be coded with nothing more than a 12 key keypad?

The answer is yes.  So, I have come up with an initial set of opcodes for programming with nothing more than what is on my workspace. 

This language would more resemble CHIP-8 than, say, the Arduino language.  Commands, statements and functions all use a single byte but can have one or more subsequent values for parameters.

The tables below outline the main features. The keypad I am using (because it was less than a buck) does not have enough keys for full hexadecimal, so I had to improvise. Still working on a scheme to allow alphanumeric entry without connecting a full ASCII keyboard.  For now, the language will be limited to reading sensors, accepting decimal (though integer only) numbers. No video, serial out to the 2×16 LCD or a Bluetooth module.

For the tables, the first column is the opcode, second is what the opcode does, third is any parameter( s ) necessary and the last is a description.

Assignment:

01

Let

Var (00-0F)

Value (00-FF)

Conditionals:

02

IF

Var (00-0F)

01 is equal, 02 is <, 03 is >, 04 is <>

03

Jump if true

Addr (00-FF)

 

Program Flow:

04

Goto

Addr (00-FF)

Transfer control to address

05

Call

Addr (00-FF)

Call a subroutine

06

Return

   

07

End

 

Ends program

Input/Output

10

Inkey

Var (00-0F)

Gets input from the keyboard

11

Out

Var (00-0F)

Outputs a value

12

Temp

Var (00-0F)

Gets a reading from the temperature sensor

13

Pinset

00-FF

Send a value to pin

14

Pinread

00-FF

Get a value from pin

15

Xfer Pin

Var (00-0F)

Transfers value from read pin to variable

I would envision the interpreter being fairly small, so it may be possible to integrate several libraries for the more popular sensors, like DHT-11 temp sensor and others.

So, what do you think?  Is this something of interest? Please post your thoughts in the comments below.

Type in Game: PONG! (or, something close)

WP_20160911_21_48_56_Pro (3)Today’s type in game for HB Tiny Basic is a PONG! variant.  I cannot take full credit for this one, I found the original on a Japanese educational site devoted to teaching microcontroller programming, using Half-Byte’s Tiny Basic(!) (a variation of it, anyway) and for basic electronics.  The original was written in a variant of HB Tiny Basic and also used a 10k potentiometer for the controller.  I fixed a couple of bugs, got it to work with Nunchuk AND squeezed into a somewhat smaller memory footprint.

The game has a little bit of intelligence, it does a decent job of trying to guess where the ball will go, but, it is not perfect and it is possible to win the game.  There are some nice uses of the language, such as trying to include something like an OR statement when figuring out where the ball is going and takes advantage of an undocumented ‘feature’ of LINE: if you specify ‘2’ as the ‘color’ parameter, it simply inverses the pixels in the line.  This eliminates the need for multiple statements to draw and erase the paddles.  Quite clever.

Gameplay is super simple: the computer ALWAYS serves, the score goes to nine and stops. You are always on the right. You use the thumb stick up and down to control your paddle.

Weird things are likely to happen, it is not perfect and there’s no more room for improvement (challenge?)

Anyway, have fun!

10 CLS:A=0:B=0:W=48:H=32
30 BOX 0,0,W,H,1
40 U=H/2-3:V=U
50 LINE W-5,U,W-5,U+5,2:LINE 4,V,4,V+5,2
60 CURSOR 8,1:? A:IF A=9 STOP
70 CURSOR 3,1:? B:IF B=9 STOP
80 D=1:E=1:IF (U+V)&1 E=-1
90 X=5:Y=V+3:SET X,Y
100 C=50
110 IF C>0 C=C-1:GOTO 240
120 RESET X,Y
130 X=X+D
140 IF X=0 A=A+1:GOTO 60
150 IF X=W B=B+1:GOTO 60
160 IF X=W-6 IF Y>=U IF Y<=U+6 D=-D:TONE 440,100
170 IF X=5 IF Y>=V IF Y<=V+6 D=-D:TONE 440,100
180 Y=Y+E
190 IF Y=1 E=-E
200 IF Y=H-1 E=-E
210 IF X=W-6 IF Y=U IF E=1 E=-1
220 IF X=W-6 IF Y=U+5 IF E=-1 E=1
230 SET X,Y
240 LINE W-5,U,W-5,U+5,2
250 U=H-2-PAD(1)/8
260 IF U<0 U=0
270 IF U>H-6 U=H-6
280 LINE W-5,U,W-5,U+5,2:LINE 4,V,4,V+5,2
300 IF D=1 GOTO 370
310 IF X>=28 GOTO 370
320 IF X=27 IF A<=B GOTO 370
330 IF E=1 Q=Y+X-4:IF Q>=H Q=32-H
340 IF E=0 Q=Y-X+4:IF Q<0 Q=-Q
350 IF Q<V+3 IF V>1 V=V-1
360 IF Q>V+3 IF V<25 V=V+1
370 LINE 4,V,4,V+5,2
380 RESET X,Y
400 DELAY 20:GOTO 110