[{"element_type":"image_url","content":"https://cdn-shop.adafruit.com/145x109/4870-00.jpg","metadata":{"alt":"Adafruit","caption":"Adafruit Neotrinkey"}},{"element_type":"text","content":"\n        \u003cp\u003eIt's no secret I think the NeoTrinkey is wonderful. It's small, it's cheap and it runs CircuitPython! Who could ask for more??\u003c/p\u003e\n\u003cp\u003eAs I played with it, one thing I found handy was making some helper modules to assist in building programs - three that are particularly handy are:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003ca href=\"https://github.com/mrklingon/neotrinkey/blob/main/morse.py\" target=\"_blank\"\u003emorse.py\u003c/a\u003e\u0026nbsp; - translate text to Morse code, also defines touch pads for input\n\u003cul\u003e\n\u003cli\u003edef docode(text): # display given text in Morse code\u003c/li\u003e\n\u003cli\u003edef blinknum(num,color): #count out a number in a color\u003c/li\u003e\n\u003cli\u003edef compthink(): #blink out all the colors when computer \"thinking\"\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003ca href=\"https://github.com/mrklingon/neotrinkey/blob/main/prt.py\" target=\"_blank\"\u003eprt.py\u003c/a\u003e - provides a function to print text to the REPL *OR* using HID to send it as typed text.\n\u003cul\u003e\n\u003cli\u003edef prt(text, REPL): #prints text to REPL if REPL=True; otherwise uses HID to send as typed text\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003ca href=\"https://github.com/mrklingon/neotrinkey/blob/main/ncount.py\" target=\"_blank\"\u003encount.py\u003c/a\u003e - blinks numbers, or displays 0-15 in binary.\n\u003cul\u003e\n\u003cli\u003edef docolor(color): #briefly set all pixels to color\u003c/li\u003e\n\u003cli\u003edef blinknum(num,color): #blinks num times in color\u003c/li\u003e\n\u003cli\u003edef binnum(num,color): #display num%16 in binary on pixels with color\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003e\u003cspan style=\"text-decoration: underline;\"\u003e\u003cstrong\u003eUsing The Modules\u003c/strong\u003e\u003c/span\u003e\u003c/p\u003e\n\u003cp\u003eHere's a very short program that blinks out, in Morse code some Bible verse fragments (in Klingon - my \"nickname\"\u0026nbsp;\u003cem\u003eis\u0026nbsp;\u003cstrong\u003emrklingon\u003c/strong\u003e\u003c/em\u003e, after all):\u003c/p\u003e\n\u003cp style=\"padding-left: 80px;\"\u003e\u003ccode\u003efrom morse import *\u003c/code\u003e\u003c/p\u003e\n\u003cp style=\"padding-left: 80px;\"\u003e\u003ccode\u003eJohn316 = \"vaD \u0026nbsp;joH'a' \u0026nbsp;vaj loved the \u0026nbsp;qo'\"\u003c/code\u003e\u003cbr\u003e\u003ccode\u003eIsaiah263 = \"Duvoqchugh, vaj rojna'Daq Da'av, \u0026nbsp;DuHarmo'\"\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ePsalm231 = \"DevwI'wI' ghaH joH'a''e' jIneHbe'.\"\u003c/code\u003e\u003c/p\u003e\n\u003cp style=\"padding-left: 80px;\"\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp style=\"padding-left: 80px;\"\u003e\u003ccode\u003ewhile True:\u003c/code\u003e\u003cbr\u003e\u003ccode\u003e\u0026nbsp; \u0026nbsp; docode(John316)\u003c/code\u003e\u003cbr\u003e\u003ccode\u003e\u0026nbsp; \u0026nbsp; docode(Isaiah263)\u003c/code\u003e\u003cbr\u003e\u003ccode\u003e\u0026nbsp; \u0026nbsp; docode(Psalm231)\u003c/code\u003e\u003c/p\u003e\n\u003cp style=\"padding-left: 80px;\"\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp\u003ePretty simple - it just blinks the code over and over. You could plug it into a power source and let it run - and you could choose your own text. Plugged into a computer running Mu, you would see the text being printed over and over as well.\u003c/p\u003e\n\u003cp\u003eUsing the prt.py module, I wrote \u003ca href=\"https://github.com/mrklingon/neotrinkey/blob/main/magicquest.py\" target=\"_blank\"\u003emagicquest.py\u003c/a\u003e. This uses morse.py for the touch pad initialization, and the \"compthink()\" blinking. Touching pad 1 creates a fantasy character (race, class and name), and pad 2 generates a short story about the character's adventure. I used \u003ca href=\"https://fantasynamegenerators.com\" target=\"_blank\"\u003efantasynamegenerators.com\u003c/a\u003e \u0026nbsp;to come up with place names and more.\u003c/p\u003e\n\u003cp\u003eIf you change the value of REPL in the code you can decide if the text gets printed in the REPL using Mu or Thonny, or if it is sent as if typed using a computer.\u003c/p\u003e\n\u003cp style=\"padding-left: 80px;\"\u003eREPL = False #\"printed\" text from prt() goes as if typed\u003c/p\u003e\n\u003cp style=\"padding-left: 80px;\"\u003eREPL = True #\"printed\" text goes to REPL\u003c/p\u003e\n\u003cp\u003eI\u0026nbsp; used the ncount.py module's binnum() function in two progams, \u003ca title=\"cards.py\" href=\"https://github.com/mrklingon/neotrinkey/blob/main/cards.py\" target=\"_blank\"\u003ecards.py\u003c/a\u003e\u0026nbsp;and \u003ca title=\"orbit.py\" href=\"https://github.com/mrklingon/neotrinkey/blob/main/orbit.py\" target=\"_blank\"\u003eorbit.py.\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003eFor the cards.py program, the neotrinkey shuffles a deck of cards when you touch pad1, and pad2 draws a card and prints it in the REPL but displays it as a binary number (1-13) and color\u0026nbsp;\u003c/p\u003e\n\u003cp style=\"padding-left: 80px;\"\u003esuits = [\"diamonds\",\"clubs\",\"hearts\",\"spades\"]\u003cbr\u003escolor = [gold,blue,red,green]\u003c/p\u003e\n\u003cp\u003eTouching 1 and 2 together shuffles and draws three cards.\u003c/p\u003e\n\u003cp\u003eorbit.py blinks a purple NeoPixel around and around at a speed (sort-of) appropriate to the planet the ship is at - from Mercury to Pluto. This uses binnum() to light up the number 1,2,4, or 8\u0026nbsp; to move the position around and around the four NeoPixels. Touching pad 1 makes all NeoPixels flash gold (closer to the sun) and shifts to the planet that is next closer to the sun. Touching pad 2 makes all NeoPixels flash blue (farther from the sun) and shifts to the planet next farther out.\u003c/p\u003e\n\u003cp\u003ePads 1\u0026amp;2 together make jump the position either to Mercury or Pluto depending on whether you are closer than Mars or at Mar or farther out.\u003c/p\u003e\n\u003cp\u003eThe name of the target planet is printed to the REPL and the orbit speed speeds up or slows down depending on which direction you have moved. (Note: the \"speed\" is just a factor based the position (planet 1-9) divided by ten. It is not really correct for the real planets).\u0026nbsp;\u003c/p\u003e\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\n      ","metadata":{}}]