I want to create a list of names on my Arduino. I want to be able to add a name to the list, I want to be able to remove a certain name from the list and I want to be able to check if a certain name exists in the list.
As far as I understand I need to use something called EEPROM?
BTW. I might gotten something all wrong, please tell me.
EEPROM means programmable for multiple times. Not mean storage. If you want to store list while the device is running, it is possible. Define an array like standard way. You can search in that array, add names to array by using arduino console. These are depends on your code.
But if you want to store your array all the time (even device is closed) you need a storage device such as sd card or something like this.
It is possible to store data in the EEPROM, but depending on the Arduino model there isn't much space. You would be better off using an SD card shield.
Related
This past year, I took a coding class on creating games using javascript. It is a basic game like Asteroids. When the game ends, it shows the top 5 high scores. The only problem is that when the program is restarted, the array that holds the scores is reset.
I want to store the high scores in a text file or spreadsheet. But, I cannot find a way to get my program to pull information from an outside file and assign it to either a variable, or I would rather put it into an array.
The second part is that when the game ends, it would need to send the updated array to the outside file if it is updated. Everything I look up involves HTML and CSS and we didn't learn this.
Is there any viable way to do this in Javascript?
It seems like the question is 'how do I read and write files from javascript'? The answer largely depends on where you're running the Javascript.
It doesn't sound like you're working in a browser, which makes it likely that you're using Node JS. If this is the case, you'll want to look at the File System API. Specifically, you'll want to create a filehandle by using fsPromises.open(). Once you have this reference to a location on your hard drive, you'll use filehandle.writeFile() to write a string directly to the file, and filehandle.readFile() to read a string directly from the same file.
I am working on mixing more audios with ffmpeg amix filter.I am able to achieve this using command line ,but I want to achieve the same with ffmpeg APIs.I have gone through the examples filtering_audio but it only takes one input . Can anyone tell me how to use multiple inputs for a filter? My purpose is to replace main audio with some other audio whenever there is data on second input.If there is no data on second input ,the filter should go on with one input.
Use avfilter_graph_alloc() to allocate avfilter graph as usual.
Create filter graph by avfilter_graph_parse_ptr() or avfilter_graph_parse2(). The former one will need you to create AVFilterInOut linked list manually. Check their docs here.
I'll assume you know how to decode the audio inputs to frames here. So the last thing is add them to their own buffersrc. Same as one input filter process, but call av_buffersrc_add_frame() multiple times in order.
There's an example written in Chinese. The code is not hard to understand, though some of them need a little fix for compatibility.
Hi i'm trying to store an array filled with objects so that it doesn't disappear if the app is closed completely.
The Problem:
if I use core data and convert the array to NSData then it works. But the app freezes while it's processing the array.
I've also tried the transformable datatype but i cant't get it to work.
And I can't use NSUserdefaults either because it doesn't support images.
Does anyone have an idea how i might solve this.
i'm quite a newbie to programming so this might be an entirely wrong approach.
First save the images in individual files with unique file names in an image directory in the Documents directory. Put the unique file names in the array, not the images.
Then depending on your needs either save the individual per image information in Core Data if quick random access is required. Or save the array in a file.
For 1500 strings of ~100 characters each saving in a single file is probably fine, I would start there and only move up to Core Data if there is a performance problem Core Data would resolve it.
As Ken Beck says: "Do the simplest thing that could possibly work." I don't believe that having 750 images in the array would really work if they were of any substantial size.
Do not use NSUserDefaults.
Core Data is overkill for simply saving an array to disk.
What kind of objects are you saving?
If you already have logic to convert the array to NSData why not just save the file to either your documents directory or caches directory (caches if it can be recreated if purged, documents if it is unique and contains user state info.)
Edit:
zaph raises some good points in his question. How big is this array (number of elements and total data size.) Is it reasonable to load it all into memory?
If you are looking for a random-access way to load one element at a time, then a database might be reasonable.
The specific solution depends on the particulars of your problem, so we need more info.
I want to play a media file from a memory stream using LibVLC like so:
//Ideally it would go like this:
LibVLC.MediaFromStream = new MemoryStream(File.ReadAllBytes(File_Path));
Of course this is a very oversimplified version of what I want but hopefully it conveys what I am looking for.
The reason being that I want there to be a good amount of portability for what I'm doing without having to track file locations and such. I'd rather have a massive clump of data in a single file that can be read from than have to track the locations of one or many more files.
I know this has something to do with the LibVLC IMEM Access module. However, looking at what information I've been able to find on that, I feel like I've been tossed from a plane and have just a few minutes to learn how to fly before I hit the ground.
See my answer to a similar question here:
https://stackoverflow.com/a/31316867/2202445
In summary, the API:
libvlc_media_t* libvlc_media_new_callbacks (libvlc_instance_t * instance,
libvlc_media_open_cb open_cb,
libvlc_media_read_cb read_cb,
libvlc_media_seek_cb seek_cb,
libvlc_media_close_cb close_cb,
void * opaque)
allows just this. The four callbacks must be implemented, although the documentation states the seek callback is not always necessary, see the libVlc documentation. I give an example of a partial implementation in the above answer.
There is no LibVLC API for imem, at least not presently.
You can however still use imem in your LibVLC application, but it's not straightforward...
If you do vlc -H | grep imem you will see something like this (this is just some of the options, there are others too):
--imem-get <string> Get function
--imem-release <string> Release function
--imem-cookie <string> Callback cookie string
--imem-data <string> Callback data
You can pass values for these switches either when you create your libvlc instance via libvlc_new(), or when you prepare media via libvlc_media_add_option().
Getting the needed values for these switches is a bit trickier, since you need to pass the actual in-memory address (pointer) to the callback functions you declare in your own application. You end up passing something like "--imem-get 812911313", for example.
There are downsides to doing it this way, e.g. you may not be able to seek backwards/forwards in the stream.
I've done this successfully in Java, but not C# (never tried).
An alternative to consider if you want to play the media data stored in a file, is to store your media in a zip or rar since vlc has plugins to play media from directly inside such archives.
I working on a project in a microcontroller and I need to persist some settings. Pretend this is an iPod. I need to save various settings like CurrentSongPlaying, CurrentVolume, etc. so that when I turn on again I can restore those settings. The trouble I'm running into is that makes sense to store all my Non-Volatile Settings in a single struct that I can serialize/de-serialize from memory but I can't find a way to make that happen without the class doing the serialization/de-serialization from non-volatile memory including every class that contains a setting that will need to be saved for size/type information. Is there some sort of design pattern that will allow me to persist all these settings to memory without having to know about what I'm saving?
Looks like you just need an associative array. An associative array (or map) is a container that allows you to map different values to unique keys. It can have a fixed or dynamic size depending on the implementation. Coupled with a proper serialization mechanism, it allows you to save and restore its state without having to know its content in advance.
However, C does not provide this data structure out-of-the-box. Look at this question for a few implementations. The most common implementation is the hash table, also called a hash map.
OOP and classes are not easy to implement in C.
If using C is a must, I would write the struct to file.
Then I would read them and parse them during initialization upon reboot.
You can think of this as serializing your structs yourself.