Digistump Forums

The Digispark => Digispark Pro Support => Topic started by: netguy204 on June 24, 2014, 06:22:25 pm

Title: What are you doing with your Beta Shield?
Post by: netguy204 on June 24, 2014, 06:22:25 pm
I wrote some code that uses everything on the board! Finding a use for the light sensor was a challenge so I made it auto-dim the array if you're in a dark room.

https://gist.github.com/netguy204/7c336bbdbe50113b2abc (https://gist.github.com/netguy204/7c336bbdbe50113b2abc)

Would love to see what others come up with.
Title: Re: What are you doing with your Beta Shield?
Post by: jaolen on June 25, 2014, 10:00:54 am
What is the beta board? I'm pretty sure my beta board will get here next week if at all - it was supposed to go from Portland -> Denver, and is currently in a sorting facility in Anchorage. :/
Title: Re: What are you doing with your Beta Shield?
Post by: netguy204 on June 25, 2014, 02:42:39 pm
It's described (lightly) on the Kickstarter page. It has an 8x8 LED matrix, a light sensor, and a 2 axis joystick with integrated pushbutton.

(https://s3.amazonaws.com/ksr/assets/002/051/492/6ef3983ff188369f9adc97bfb5326c4e_large.jpg?1400928349)
Title: Re: What are you doing with your Beta Shield?
Post by: defragster on June 25, 2014, 04:56:17 pm
It is a bag of a parts!  I got mine today!  Looking forward to making it go.

http://digistump.com/wiki/digispark/tutorials/probetashield (http://digistump.com/wiki/digispark/tutorials/probetashield)

Great Topic netguy204 - I saw your code on the WIKI!  Your question popped up TWO ideas for me.  I'll come back with them when I have properly blinking lights.
Title: Re: What are you doing with your Beta Shield?
Post by: ubersmack on June 26, 2014, 10:11:23 pm
Well I just got it put together.. now to get something running on it..

(http://i.imgur.com/OEgAuZ6.jpg)
Title: Re: What are you doing with your Beta Shield?
Post by: cheetahkid on June 27, 2014, 01:13:40 pm
I got mine today and really is a surprised ;D, now to put things together (first thing first, the blinker to see if it works)
Title: Re: What are you doing with your Beta Shield?
Post by: defragster on June 27, 2014, 01:55:42 pm
Added PRO image to the wiki from Kickstarter

http://digistump.com/wiki/digispark/tutorials/headers#assembly (http://digistump.com/wiki/digispark/tutorials/headers#assembly)

(http://digistump.com/wiki/_media/digispark/tutorials/digisparkpro.png)
Title: Re: What are you doing with your Beta Shield?
Post by: netguy204 on June 27, 2014, 07:10:48 pm
Ladies and Gentlemen,

I proudly present: BetaInvaders!

https://github.com/netguy204/BetaInvaders/archive/master.zip
Title: Re: What are you doing with your Beta Shield?
Post by: Eascen on June 28, 2014, 01:13:04 pm
That... is epic, thank you!
Title: Re: What are you doing with your Beta Shield?
Post by: wbp on June 30, 2014, 03:17:23 pm
I got the BetaBoard sample to run without any problems, but when I try to load Beta Invaders it will not run. As a test I added some code to Setup to light up all the pixels, copied from my working sketch, and that did not run. I started cutting the sketch down in size by removing (commenting) sections of code, and eventually got it to run the code in Setup.

The Invaders sketch isn't that large. Any idea what's going on? Do I have a defective mcu?
Title: Re: What are you doing with your Beta Shield?
Post by: wbp on June 30, 2014, 03:59:49 pm
Got it working! Had to reduce the array sizes. If I set MAX_ENEMIES 15 and MAX_BULLETS 30 it runs, and the compiler shows 414 bytes of dynamic memory. If I use 15 and 35 (444 bytes) it runs. With 15 and 40 (474 bytes) it fails.

Bug in the IDE? I'll see if there is a new nightly build.

William
Title: Re: What are you doing with your Beta Shield?
Post by: defragster on June 30, 2014, 04:19:22 pm
System stack and any libraries may be using ram as well that is getting hit
Title: Re: What are you doing with your Beta Shield?
Post by: cheetahkid on June 30, 2014, 04:22:29 pm
I got the BetaBoard sample to run and found problem, I found the push button is short circuited and it need a replacement (pushbutton is part of the joystick)  :-\
Title: Re: What are you doing with your Beta Shield?
Post by: wbp on June 30, 2014, 08:19:39 pm
cheetakid - check that the switch is all the way down against the circuit board. There are only 2 small metal arms that hold the switch in place, and I found they bent easily. If the switch is not pressed down against the board this might cause it to be "pressed" all the time. I hope this helps.
William
Title: Re: What are you doing with your Beta Shield?
Post by: cheetahkid on June 30, 2014, 09:39:17 pm
cheetakid - check that the switch is all the way down against the circuit board. There are only 2 small metal arms that hold the switch in place, and I found they bent easily. If the switch is not pressed down against the board this might cause it to be "pressed" all the time. I hope this helps.
William
I already checked, there a lots of play and nothing is pressed, thank but still s/c
Title: Re: What are you doing with your Beta Shield?
Post by: defragster on June 30, 2014, 10:08:15 pm
there are four switch leads - the thinnest of them all - when I placed mine I watched two - and folded two - pulled and made right and then soldered.  Doing PRO downloads now to see how it goes.
Title: Re: What are you doing with your Beta Shield?
Post by: netguy204 on July 01, 2014, 03:09:54 am
@wbp @defragster - Correct, not sure how it ever worked for me but the system stack and the enemies/bullets array were interacting.

I've updated the project to make more conservative choices on enemy and bullet array sizes and will eventually go back and tighten up those structures a bit so that more enemies can fit on the pro. The numbers I chose (conservatively) were 15 and 15.
Title: Re: What are you doing with your Beta Shield?
Post by: cheetahkid on July 01, 2014, 10:20:07 am
it isn't the button, it the track and yep, PCB track fault with D1 short circuit to 0V under the matrix leds. Looks like no go for me.
(not sure either it need a replacement or repair the track? let me know)
Title: Re: What are you doing with your Beta Shield?
Post by: defragster on July 01, 2014, 10:44:02 am
cheetahkid > Interesting to know if all works if you can jumper past it - meaning no other faults on the board.

QUESTION: On power up does the MATRIX go all 6 seconds on for others?  Demo works after that.  If so that would be interesting diagnostic to document.  UPDATE: Mine must go ALL_ON about 90%, but I did get one group where it powered up 'all_off'.  Sometimes it powers up and won't go into run mode - it will sit ALL_ON or all_off.

Good work netguy204.  The device used RAM isn't known to the compiler, but it is there.

Title: Re: What are you doing with your Beta Shield?
Post by: netguy204 on July 01, 2014, 10:54:57 am
@defragster: Sometimes my whole display lights up on power up but it's not consistent.
Title: Re: What are you doing with your Beta Shield?
Post by: cheetahkid on July 01, 2014, 12:23:12 pm
I am not sure, using the demo if it all lit up on the matrix that when my switch fault does that.
I tried turn it off by

on part of the demo matrix ...
if(!digitalRead(BUTTON)) {    // This bit I remove the "!" and it will turn off (that with the fault).
    for(int x = 0; x < 8; x++) {
      for(int y = 0; y < 8; y++) {
        lc.setLed(0, x, y, true);
      }
    }

try it to see any different?

I haven't yet to repair my board atm.
Title: Re: What are you doing with your Beta Shield?
Post by: defragster on July 01, 2014, 12:42:55 pm
I saw FULL_ON after assembly with factory blink installed.  The first 6 seconds the code isn't running yet (waiting for new program) so this is a hardware power up on the multiplexer etc. - I thought it might have been more deterministic.

Indeed - once the code starts it works right, but as noted I have seen it not always start, sat with all lights on over 5 mins at least once so there is a brownout/race state or something.  Haven't tried without beta shield to see if it is the Pro or the shield at the root of that.
Title: Re: What are you doing with your Beta Shield?
Post by: cheetahkid on July 01, 2014, 02:30:21 pm
oh yes that did happen to me sometime, full bright on, when you say brown out, it happens to me when I moved it or touch it (there are pins sticking out in the back and trying not to touch them)... sound like the program isn't complete or working, it will work second try or bring it back to blinker test (use the start program), I don't know how it does that but could be something conflint with usb on computer side, just a guess.
Title: Re: What are you doing with your Beta Shield?
Post by: SoLongSidekick on July 01, 2014, 06:54:18 pm
I came here to post this exact thread, and BetaInvaders is AWESOME!! Thanks dude! I've got some ideas, but little Digispark programming experience.

An etch-a-sketch type-thing would be cool. Flashing dot displays where the cursor is, pressing the stick plops a pixel down. Moving the stick obviously moves the cursor around the matrix. Maybe covering the LDR wipes the matrix or something. A snake remake is a pretty obvious one as well.

Robotic motor control would be really cool. Using the stick to either engage lateral motion motors or rotation servos would be perfect for this board. I soldered my LDR just about flush (if not a little above) the upper rim of the LED matrix so I could effectively cover it with a fingertip without having to squeeze down between components. Covering the LDR could decrease speed or acceleration in the motors or something similar.

Other than robotic control this board is pretty useless. I was pretty disappointed when I found out what it was. It's fun no doubt, I guess I was just hoping for something a little more complex. I think I just read into the "Beta" part of it a little too much. I'm realizing it's difficult to power the board with a shield attached; the USB port can't take more than 5.5v and all the power pins aren't easily accessible without soldering to them.

What would be REALLY slick is if it was used to control a robot with an ultrasonic distance sensor that displayed any walls on the matrix so you could have a basic sort of sonar.
Title: Re: What are you doing with your Beta Shield?
Post by: defragster on July 02, 2014, 01:47:40 am
Starting with http://pastebin.com/nLutVY1z (http://pastebin.com/nLutVY1z)'s source I have extended random thoughts I had from the starting access to everything provided.

I minimized it by taking 100 code lines up to 150 while not adding a single comment! But with a higher light blink factor it uses the same 114 bytes of dynamic memory.

Attach the archived project with a ReadMe.

One Oddity I found is that the X and Y read and run the screen 'relatively' right, but asking for the X or Y input value to use in the code requires moving the wrong axis for these lines:
> BusyWait = ypos;
> RandomFill(xpos);
Maybe I missed news of the X Y axis shift?  But just swapping the joy ports makes the display wrong so it is twisted in the MUX too.
Title: Re: What are you doing with your Beta Shield?
Post by: digistump on July 02, 2014, 11:43:51 am
it isn't the button, it the track and yep, PCB track fault with D1 short circuit to 0V under the matrix leds. Looks like no go for me.
(not sure either it need a replacement or repair the track? let me know)

We'd be happy to replace your board/kit if it has a bad PCB - all PCBs are tested at the fabrication company, but sometimes one slips through. If you want a replacement send us an email support at digistump dot com
Title: Re: What are you doing with your Beta Shield?
Post by: TravisF on July 02, 2014, 12:17:01 pm
I finally got my board working again and flashed the space invaders game. Wow! That is way better than I would have been able to do. 
Title: Re: What are you doing with your Beta Shield?
Post by: defragster on July 02, 2014, 09:48:29 pm
@netguy204 - Code runs for me and the game looks good!  Given the screen size and element counts one byte char variables are good enough for all the data rather than an int.  I also deleted the unused analog read of the Ypos.

I rebuilt swapping the char for int and here is how the upload changes with 24 enemies and 15 bullets:
CHAR:: Sketch uses 3,770 bytes.   Global variables use 247 bytes of dynamic memory.
INT   :: Sketch uses 4,032 bytes    Global variables use 396 bytes of dynamic memory.

Given the 8bit cpu the drop in code size means less overhead doing two byte math.
{ for fun testing I made the enemy bullets kill them when player was hit and it ran game after game! }
Title: Re: What are you doing with your Beta Shield?
Post by: netguy204 on July 03, 2014, 11:32:53 am
Good call! For some reason I had believed that sizeof(int) == 1 on an 8 bit AVR. All of my code now suddenly takes less memory now that my error is corrected.

Updated the BetaInvaders zip with @defragster's excellent insight (though chose int8_t and uint8_t instead of char to be more overtly explicit.)
Title: Re: What are you doing with your Beta Shield?
Post by: netguy204 on July 03, 2014, 07:33:56 pm
@SoLongSidekick, you inspired me to create an etch-a-sketch. Thanks for the cool idea!

Ladies and gentlemen, "BetaSketcher!" https://github.com/netguy204/BetaSketcher/archive/master.zip

The cool technical feature of this sketch is that it's using Binary Angle Modulation to actually drive the 8x8 array with multiple simultaneous shades of red. I broke that portion of the code into its own Digispark Pro specific Arduino library called "BAM". The BAM strategy requires the sketch to continuously shift new rows into the MAX 7219 very rapidly. It's Pro specific because it uses the SPI hardware to shift out new values to the matrix as quickly as possible. It also uses the pro's 16 bit timer and compare-match interrupt to keep the display refresh cycle happening in the background while the logic runs in the standard loop() function. The end result is effectively an independent 8 bit software PWM for each individual LED in the matrix. Pretty cool technique!
Title: Re: What are you doing with your Beta Shield?
Post by: defragster on July 03, 2014, 09:55:49 pm
@netguy204 compiled AND WORKS ... with this edit to BAM.cpp line~14

//prog_
const uint8_t CIEL8[] PROGMEM = {
Title: Re: What are you doing with your Beta Shield?
Post by: defragster on July 03, 2014, 10:15:05 pm
@netguy204  :: AWESOME BAM shading work - interesting functional intuitive UI!

I edited BetaSketcher code at line 71 as follows to allow a PIXEL clear, and to protect the image from a shadow (or flash):

  if(!digitalRead(BUTTON)) {
    if (7 == screen[peny][penx])
      screen[peny][penx] = 0;  // Reset BRIGHT pixel to off
    else
      screen[peny][penx] = min(7, screen[peny][penx] + 1);
  }
 
  // clear the screen on significant light change if joystick DOWN
  if(abs(light_neutral - analogRead(LIGHT)) > light_neutral / 2 && (dy < LIVEZONE)) {
    memset(screen, 0, sizeof(screen));
  }
Title: Re: What are you doing with your Beta Shield?
Post by: netguy204 on July 04, 2014, 05:06:12 am
Not sure why you needed the PROGMEM edit (worked fine for me and I'm pretty sure there's nothing special about my configuration). But, pulled in that change for compatibility.

I want to think more about how to clear pixels. I like being able to hold down the joystick button as I sweep back and forth until the line is full bright. I tend to reintroduce dead pixels after this change.

I made the light sensor respond only to darkening. I was having the "rotating the board towards light clears my art" problem too. Things feel pretty good after this change.
Title: Re: What are you doing with your Beta Shield?
Post by: defragster on July 04, 2014, 12:40:42 pm
I saw the sweep was affected - which is the joy of an etchasketch - I was started to code a check on change of x,y before and after the penXY updates.  So the 0 dim only happens when the joy is standing. 

This is better but still goes off on ends and uplifting pixel:
  int movexy=penx+(10*peny);
...
  if(!digitalRead(BUTTON)) {
    if (7 == screen[peny][penx] && (penx+(10*peny)==  movexy))
Title: Re: What are you doing with your Beta Shield?
Post by: pitchakorn on May 20, 2019, 09:53:01 pm
Ok  good
ufabet (http://www.ufabet99.vip)