TinyCircuits

Recent Posts

Pages: 1 ... 8 9 [10]
91
Tiny Arcade / Re: Custom colors (other than the 16 pre-defined?)
« Last post by johnbbq on July 24, 2018, 09:20:39 AM »
Thank you Dulsi! I will check it out.
92
Tiny Arcade / Re: Custom colors (other than the 16 pre-defined?)
« Last post by dulsi on July 24, 2018, 07:57:03 AM »
My suggestion is to not set colors directly. Create your image in a painting program. Dowload zet23t's td2play (https://github.com/zet23t/td2play). Go to tools/js_image_converter. Load the html file into a browser. Use it to convert your images.
93
Tiny Arcade / Custom colors (other than the 16 pre-defined?)
« Last post by johnbbq on July 23, 2018, 11:25:57 PM »
Hi there. Today I have been creating new sprites for our game, and I've been having a hard time finding how I can set up an RGB color. I am not sure what's the right format.

I found this page: http://www.barth-dev.de/online/rgb565-color-picker/ . But if I use their color values (for example 0xFE82), I get a completely different color on screen.

The only colors that work well are the ones defined in the library (TS_16b_Yellow for example).

Can you tell me what format should I enter the color values for each sprite pixel?

Thank you,

94
TinyDuino / Re: Older Tinyduino Smartwatch
« Last post by JonahEmbri on July 23, 2018, 07:42:53 PM »
Sorry, its been a while since I have looked at this project.

I am currently running the default "Old kits with Nordic BLE: iOS version" that is initially given by the TinyScreen SmartWatch tutorial (https://tinycircuits.com/blogs/learn/158289927-tinyscreen-smartwatch-tutorial). In this program, the 'sleepTimeout' variable causes the smartwatch to go to sleep, which is good in my case (saves power, etc). When it does this, I am able to wake it back up by pressing one of the buttons, or when a notification from my phone is passed. The problem I am describing is similar, where the screen turns off like it is going to sleep. However, it proceeds to stay off, and I have to physically restart the Tinyduino to wake the system back up.

While this would normally be a slight annoyance, since I have the old version, the time is reset when I restart the watch (rubbing salt in the wound).  >:( >:(

I am glad to hear you have fixed the time reset problem with the newer versions. Unfortunately, this is turning into a mildly expensive reminder to do your research before buying anything  :( :'(
95
Tiny Arcade / Re: Creating sprites dynamically (on run time). Is it possible?
« Last post by johnbbq on July 22, 2018, 01:24:24 AM »
I was able to create the bullets for the game my son and I are working on. I wanted to share my solution in the thread. Please let me know if this is the right approach or if there is a way to improve it.

The first thing I did is to create an offscreen global variable I can use throughout the game:

int offscreen = -100;

I then created a bulletBitmap, and 5 sprite instances for it:

ts_sprite bullet1 = { offscreen, offscreen, 3, 4, 0, bulletBitmap };
ts_sprite bullet2 = { offscreen, offscreen, 3, 4, 0, bulletBitmap };
ts_sprite bullet3 = { offscreen, offscreen, 3, 4, 0, bulletBitmap };
ts_sprite bullet4 = { offscreen, offscreen, 3, 4, 0, bulletBitmap };
ts_sprite bullet5 = { offscreen, offscreen, 3, 4, 0, bulletBitmap };


I added these sprites to the spriteList array, but I also created a playerBulletList array, pointing to the same references. This way I could use the spriteList array just for the drawBuffer function, and keep a separate array to iterate through when I'm updating bullets:

int amtSprites = 6;
ts_sprite * spriteList[6] = { &player, &bullet1, &bullet2, &bullet3, &bullet4, &bullet5 };
int amtPlayerBullets = 5;
ts_sprite * playerBulletList[5] = { &bullet1, &bullet2, &bullet3, &bullet4, &bullet5 };


I then added two global variables:

int playerBulletIndex = 0;
int playerLastShot = 0;


playerBulletIndex allows the function to go through an index of bullets, and know which of the 5 I used last, and the playerLastShot variable records the last time in millis when a bullet was last shot.

Here is the function (added to loop() to run in every cycle):

void playerBulletsMovement() {
  //Check if button is pressed
  if (checkButton(TAButton1) && millis() > playerLastShot + 400) {
    ts_sprite *cb = playerBulletList[playerBulletIndex];
    cb->x = player.x;
    cb->y = player.y;
    playerBulletIndex += 1;
    if (playerBulletIndex > 4) playerBulletIndex = 0;
    playerLastShot = millis();
  }
 
  //Update all bullets
  for (int playerBulletIndex = 0; playerBulletIndex < amtPlayerBullets; playerBulletIndex++) {
    ts_sprite *cb = playerBulletList[playerBulletIndex];
    if (cb->y != offscreen) {
      cb->y = cb->y -1;
      if (cb->y < 0) cb->y = offscreen; 
    }
  }
}


The first part checks if the player pressed Button1 to fire a shot. But so the player doesn't fire indiscriminately, we only allow the player to fire every .4 of a second. So this part of the function only runs when both of these conditions are met.

if (checkButton(TAButton1) && millis() > playerLastShot + 400)

If the condition is met, the next step is to create a variable in order to access the bullet reference I need:
 
ts_sprite *cb = playerBulletList[playerBulletIndex];

So the first time the player presses Button1, the program requests the first bullet in the playerBulletList.

Right away I set the position of the bullet (currently offscreen) to be where the player is:

cb->x = player.x;
cb->y = player.y;


And then I move the index to the next bullet I can use:

playerBulletIndex += 1;

But I make sure that if the playerBulletIndex goes beyond the size of the array, then I reset the index to the beginning:

if (playerBulletIndex > 4) playerBulletIndex = 0;

Lastly, I store the time in millis since this shot was executed, so it can be compared by this if statement in every loop cycle:

playerLastShot = millis();

The next part of the function runs in every cycle. It is the part of the function that updates the positions of all the bullets. The structure is inspired in how the drawBuffer function works:

 //Update all bullets
  for (int playerBulletIndex = 0; playerBulletIndex < amtPlayerBullets; playerBulletIndex++) {
    ts_sprite *cb = playerBulletList[playerBulletIndex];
    if (cb->y != offscreen) {
      cb->y = cb->y -1;
      if (cb->y < 0) cb->y = offscreen; 
    }
  }

The for loop goes through all the bullets in the playerBulletIndex. The first thing I do is to create a variable to reference one bullet at a time:

ts_sprite *cb = playerBulletList[playerBulletIndex];

Then I check if the bullet is offscreen (because if it is, there is no need to update it):

if (cb->y != offscreen)

I am making a game where bullets fly vertically, from the bottom to the top of the screen:

cb->y = cb->y -1;

And lastly I check if the bullet has left the screen, to move it to the offscreen area and not update it anymore until it's used again:

if (cb->y < 0) cb->y = offscreen;

And that's it! As a last note, the amount of bullets you need may vary depending on how many you effectively can have on the screen at the same time. Be sure to include enough, but not too many as to not waste memory.

Cheers,
96
Tiny Arcade / Re: Creating sprites dynamically (on run time). Is it possible?
« Last post by johnbbq on July 20, 2018, 09:34:48 PM »
Hey Hunter, thanks for getting back to me. Makes sense, I'll create an array of bullets and bring them onscreen when I need them.

Cheers,
97
Tiny Arcade / Re: Recommendation: Amendments to the TinyArcade tutorial
« Last post by johnbbq on July 20, 2018, 09:33:18 PM »
Awesome Hunter, thank you! I'll check this out and I'll let you know how it went.

Cheers,
98
TinyDuino / Re: TinyScreen Artifacts after text replacement
« Last post by whmckinley on July 20, 2018, 09:15:24 PM »
When a temp value if first printed to the screen it shows up clearly. If the value contains a value like 67.89 when first displayed it is backed completely by black. If the temperature changes to a value that contains a 1 in it like 43.21, the original value is overwritten, But the black background does not completely cover the original 78.89, It will leave a vertical row of pixels spaced out 1 pixel to the right of the 43.21 making it look like 43.21| . This  appears to be remaining from what I believe is part of the 9 the original 67.89.  I am using the liberationSans12pt font and it appears that the sizes of the individual characters effect the display when over-writing a value.

If I add a filled rectangle

display.drawRect(51, 9,  39, 14, BLANK, BLK); // Blank out prior (DsplyF) prior to  new (DsplyF) write

display.setFont(liberationSans_12ptFontInfo); // set Font
display.setCursor(52, 10); // move Cursor to Actual Temp position
display.print(DsplyF);

        It does clear the background But I end up with a flashing (DsplyF) Not the entire display just the updated
        temperature value.

 BLANK declared as
#define BLANK  TSRectangleFilled // Defines Blank Rectangle.

I'll work tonight to duplicate with a simpler program and post that.
99
TinyDuino / Re: TinyScreen Artifacts after text replacement
« Last post by lennevia on July 20, 2018, 07:06:40 PM »
Hello!

I'm not sure if I'm understanding what you mean by artifacts, but to clear values there is a clear screen function you can use. This may be what you've already tried as it makes the screen 'blip' between prints:

  display.clearScreen();

If you're looking for something more refined, please let me know!

Thanks,
Réna
100
TinyDuino / TinyScreen Artifacts after text replacement
« Last post by whmckinley on July 20, 2018, 04:05:30 PM »
I'm developing a Thermostat controller for my RV fridge. The display has a Static border and some static text. On the display I am displaying 2 variables. A set temp and a actual temp. The Actual temp varies. When a new value is written to the display It will at times leave artifacts of the previous value.  Value of 68.88 being replaced with 65.01 will leave artifacts of the 68.88 on the trailing edge. Is there a method to just blank out the previous text. I tried doing a draw rectangle filled, but it would make the temp number constantly flash. I'm at a loss at this point.
I've attached a txt file with the project code and would appreciate any insight. BTW the set temp routine has not been fleshed out yet.

Thanks
Pages: 1 ... 8 9 [10]