SDK/OS 2.4.0 is now available!

Please note the following important changes:

  • Experimental feature: added read/write access for all games to top-level /Shared folder
    Having a way for games to share data has been a feature request for a long time. We tried to imagine all the use cases here and thought about how we’d support them, but looking at it that way it becomes a big hairy mess. So instead we’re doing the simplest thing imaginable: adding a top-level shared folder that any game can read from and write to, with no enforced structure whatsoever, and we’ll just see what happens. My hope is that after testing this out the community comes up with a set of best practices that we then build API around--or at least put into documentation. Further discussion here.
  • Added callbacks for receiving messages via the serial port msg command
          Lua: playdate.serialMessageReceived(message)
          C: playdate->system->setSerialMessageCallback(void (*callback)(const char* data));
    As a convenient way to get data into the Playdate runtime I've added a msg command that takes a string at a time and sends it to a callback. This is much easier than sending it one character at a time with btn or using eval which takes compiled Lua bytecode. Related:
  • Serial port can now receive more than 64 KB/s..which will help if you’re sending a lot of data via msg. Also you can now display full frame rate video on the device using the bitmap command. :slight_smile:
  • added playdate.setButtonQueueSize() and pd->system->setButtonCallback(), an optional button event queue and callback for more precise button handling. These lets you detect multiple button presses in one update cycle. In Lua you get the normal playdate.XButttonDown/Up() callback and in C you pass in a callback function. In both cases the callback function is passed the time of the event, in case that’s useful.
  • C API: added pd->system->parseString()
  • C API: added pd->system->vaFormatString()
    These provide the libc functions sscanf() and vasprintf(), respectively. You don’t miss them until you need them!
  • added MicSource enum to pd->sound->setMicCallback to specify internal/headset/either source
  • added optional source arg (“internal” or “headset”) to snd.micinput.startListening()
    The Playdate hardware has a chip (TS3S227E, if you’re curious) that automatically detects whether something plugged into the headphone jack has a microphone and which pin layout (standard vs OMTP) it uses. It works great for normal headphones but it can get in the way if you’re trying to use a speaker/mic splitter to connect an external source to the microphone. These functions give manual control over the mic source so we no longer need to cross fingers and perform dark rituals to get the connection working.
  • C API: added copyUserdata callback function to synth->setGenerator
  • C API: added synth->copy()
  • Copied sample synths and wavetable synths now work correctly
    Before this release we had a bug where synths created with the Lua synth:copy() function didn’t create a new instance of the generator’s userdata but instead pointed to the original. To fix this we’ve added a copy callback in setGenerator() that you use to make a unique copy of the userdata for the copied synth’s generator. If the userdata only contains scalar values, you can just alloc a new userdata and memcpy() the original into it; if it contains references to other objects you might need to also duplicate those, or retain them if they use reference counting.
    We’ve deprecated the existing function by renaming it to setGenerator_deprecated() and added the new argument to a new API function named setGenerator(). This means that existing code will continue to use the old function, but if you recompile against the new API you’ll get an error that your setGenerator() call is missing an argument. Hopefully that’s not too confusing.. I thought it was better than mucking up the API by adding setGeneratorWithCopyUserdata() or something like that.
    One handy consequence of this is you can now use synth:copy() (or the new C API synth->copy()) to add multiple voices for polyphonic instruments, instead of building each voice from scratch as was previously required. I’ve updated the Lua MIDIPlayer and DrumMachine and C API bach.mid examples to use this.

Check the changelog for what's been updated and please post a new thread in SDK Bug Reports if you run into any problems.

13 Likes

Fantastic set of changes here! Really looking forward to seeing what folks are able to do with the shared folder and msg command!

1 Like

Love seeing how the capabilities of this thing are evolving, excited to see what people do with it! In theory, with the new serial receive command, if you connected 2 Playdates via a usb-c cable, could they talk to one another?

Not currently because there's no way to establish a USB-serial connection between devices.

Not sure if this is a bug of new fw or I had been unfortunate but I had the newest fw recently today the stable came out so I updated, everything fine and after usb data transfer mode I ended it with pressing A and after restart completely empty playdate. Everything gone :cry: went to menu and games free memory 3.6 GB , downloading all the games and checking the save files if missing or not.

Is this already used by Mirror? Wondering if there is a way to increase throughput on mirror so that games higher than 30fps don't run slow

This change is to support sending data to the Playdate, like for streaming video to it. I don't know but I suspect the issue with mirror boils down to CPU speed and less USB throughput. @dave what do you think?

Hi, do you mean to say that you downloaded the update over wifi and when the device restarted all your games were gone? You should try mounting your data disk again and using your OS disk repair tool in case there is filesystem corruption.

I had the 2.4.0 beta before. Today official 2.4.0 and still everything ok. Then during the day I used the data mode, then disconnected and lost every single game and in settings there was 3.6 GB free. After mounting back I discovered that saves remained also screenshots. Now redownload games, took half day and refusing to mount again :grinning:

It sounds like forcing a restart with A instead of unmounting the disk on the computer side has corrupted the disk--if the computer doesn't have a chance to flush queued changes it can leave the filesystem in a bad state. :frowning: As James says, your best bet right now is to use a repair tool to try and fix the filesystem. On macOS, that's Disk Utility.app. I'm not sure about Windows or Linux.

Right, Mirror goes the other direction, sending instead of receiving. But I'll take a look and see if it's got a similar situation where the USB buffer is too small and causing the device to stall waiting for data to be sent.

3 Likes

Hello, since update, m'y Playdate can't connect to wifi...