Showing posts with label hacking. Show all posts
Showing posts with label hacking. Show all posts

Thursday, February 29, 2024

Hacking a 3ds to add parental controls


 

The 3ds is an amazing piece of hardware. Especially if you hack it to add homebrew/emulators.

My son has been enjoying a bit of "free time" before bed, and playing with a generic "mini arcade" game system. The games are all generic knock offs, and I figured he'd love to play with my hacked 3ds which has thousands of high quality games...

The problem is, the 3ds doesn't have "screen time" controls to encourage him to put it down after X minutes so he gets some sleep. So I decided to download the source for the custom firmware I was using (https://github.com/LumaTeam/Luma3DS) and add the controls myself.

Because I wanted the parental controls to pause the game, and allow "sleep" to save his game, I had to add my code to the firmware itself. This lets me spawn a thread that is running in the background, even when a game is running to keep track of time, and screen time limits. I added the ability to call out to my website with the current game he's playing (so in the future if we want to have certain educational games count for less time, we can)

The basic logic is this: Every few seconds it sends the current game he's playing to my sever, which responds with the screen time limit. In order for this to work "offline" if we are not at home/near internet, it has a built in "default" time of 15 minutes. It then writes to a local file every second to keep track of actual screen time usage. Then if the current screen time usage is over the screen time limit, it pauses the OS, and pops up a screen telling him that his screen time is up.

It also has a hint on how to add more screen time (he's learning to read, so if he figures this out on his own, he deserves the bonus screen time) This is also a way for us to add more time if we need locally. We can add screen time via my server as well.

So far its working great, and just about ready for "prime time" (had some issues with the 3ds getting stuck in sleep mode, but I'm just about done with that.

Once I am finished with the code, I'll upload it all to GitHub so other parents can enjoy :)

Code is gross, but functional. I'll be adding more features as I need them. 
https://github.com/spiffomatic64/Luma3DS


Wednesday, December 13, 2023

Tonie Weather

 So my son loves his tonie so much for listening to his favorite shows: blog post about that project here


I thought it would be cool to make one of his tonies tell him the weather for the day. So I threw this script together to generate a "text to speech" weather forecast for the day, and clothing recommendations for him to dress himself.

It runs every day to get the current weather, and uses the hourly high/lows and precipitation data to recommend what to wear. He wakes up in the morning, puts the yeti tonie on the box, and then knows exactly what to wear for the day.

He loves it.




Here is the code: https://github.com/spiffomatic64/tonie_sync/blob/master/tonie_weather.py


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from noaa_sdk import NOAA
import json
from gtts import gTTS
import shutil
from pprint import pprint
from datetime import datetime, timedelta


def get_temp(temp, low):
    temps = {100: "Very hot, Wear a Tshirt and shorts",
             85: "Hot, Wear a Tshirt and shorts",
             75: "Warm, Wear a Tshirt and shorts",
             65: "Nice, Wear a Tshirt and shorts",
             50: "Cool, Wear a Tshirt and pants",
             40: "Cold, Wear a Long Sleeves shirt and pants",
             30: "Very Cold, Wear a Long Sleeves shirt and pants"}

    for t in temps:
        if temp > t:
            if low < 65:
                temp_data = temps[t].replace("shorts","pants")
            return temp_data


def get_forcast(forecast_data, hourly_data):
    json_formatted_str = json.dumps(forecast_data, indent=2)
    print(json_formatted_str)

    tomorrow = datetime.now() + timedelta(1)
    tomorrow_string = tomorrow.strftime("%Y-%m-%d")
    # print(tomorrow_string)
    max = 0
    min = 100
    for hour_data in hourly_data:
        if hour_data['startTime'][:10] == tomorrow_string:
            hour = int(hour_data['startTime'][11:13])

            if hour > 6 and hour < 17:
                # print(hour)
                if hour_data['temperature'] > max:
                    max = hour_data['temperature']
                if hour_data['temperature'] < min:
                    min = hour_data['temperature']

    print(f"High: {max} Low: {min}")
    temp = get_temp(forecast_data['temperature'], min)
    forcast_string = (f"{forecast_data['name']} will be {temp}. " +
                      f"The forecast is {forecast_data['detailedForecast']} " +
                      f"The Low will be {min}")
    return forcast_string


n = NOAA()
res = n.get_forecasts('19067', 'US', type="forecast")
res2 = n.get_forecasts('19067', 'US', type="forecastHourly")
forecast = get_forcast(res[2], res2)
print(forecast)

myobj = gTTS(text=forecast, lang="en", slow=True)

# Saving the converted audio in a mp3 file named
# welcome
path = "I:\\audio\\weather"
filename = "weather"
ext = "mp3"

myobj.save(f"{path}\\{filename}0.{ext}")
for num in range(1, 3):
    shutil.copy(f"{path}\\{filename}0.{ext}", f"{path}\\{filename}{num}.{ext}")

Thursday, January 26, 2023

Tonie randomizer

 So recently my son has been asking for new audio on his TonieBox. Most of the time he falls asleep before the 2nd/3rd/4th chapter/audio play, so I decided to make an automated tonie-shuffle script.

A toniebox is basically an mp3 player, that lets you pick what audio you want by using little action figures (it uses rfid similar to amiibo like the switch). You can also upload your own audio with special creative tonies. I use these tonies to upload audio from his favorite tv shows.

This batch script rips the audio from "totally legally" obtained tv shows.


If there is interest (comment or contact me irl/elsewhere) I could hack together a easier to use web-version, maybe even make it take youtube videos/playlists/spotify/etc)


1
for /r %%i in (*.mkv) do ffmpeg -y -err_detect ignore_err -i "%%i" -map 0:a:0 -c copy -c:a aac "%%~ni.m4a" 


This python script gets all the tonies, wipes them, and associates each creative tonie with a specific folder. Then gets all the audio files in that folder, shuffles them, and keeps adding them until the tonie is full.

Simple script, but should provide a bunch of fresh bedtime "stories" for him to fall asleep with.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import os
import logging
import random
import ffmpeg
from tonie_api import TonieAPI

//dictionary of toniename, to sub-folder to associate specific tonies with specific shows
my_tonies = {'Blue': 'sonic prime',
             'Blue Hero': 'ultimate spiderman',
             'Gray': 'octonauts',
             'Green': 'teen titans go',
             'Pink': 'miraculous',
             'Pink Hero': 'spectacular spiderman',
             'Pirate': 'tmnt',
             'Vampire': 'marvels spiderman'
             }

path = "folder containing audio"

dry_run = True


def get_all(path):
    files = []
    count = 0

    for (dirpath, dirnames, filenames) in os.walk(path):
        for filename in filenames:
            full_path = os.path.join(dirpath, filename)
            files.append(full_path)
    print("")
    return files


# set up detailed logging
logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)

api = TonieAPI('your@email.com, 'password')

# update all housholds, returns IDs of households
households = api.households_update()
for household in households:
    if households[household] == 'HOUSEHOLD NAME':
        our_household = household

print(f"Our HousedholdID: {our_household}")

# update all creative tonies, returns IDs of creative tonies
tonies = api.households[our_household].creativetonies_update()
print(tonies)

for tonie in tonies:
    print(f"\nTonie Id: {tonie} Name: {tonies[tonie]} Audio: {my_tonies[tonies[tonie]]}")
    audio_folder = f"{path}\\{my_tonies[tonies[tonie]]}"
    time_left = 5400

    if os.path.exists(audio_folder):
        if not dry_run:
            api.households[our_household].creativetonies[tonie].remove_all_chapters()
        print(f"Cleared tonie: {tonie}")
        files = get_all(audio_folder)
        random.shuffle(files)
        for file in files:
            info = ffmpeg.probe(file)
            duration = float(info['format']['duration'])
            if duration < time_left:
                time_left = time_left - duration
                filename = os.path.split(file)[1]
                print(f"Uploading: {filename} duration:{duration} left: {time_left}")
                if not dry_run:
                    api.households[our_household].creativetonies[tonie].upload(file, filename)
    else:
        print("Skipping...")

Thursday, April 29, 2021

Hacking class

 I gave another hacking class to a group of high schoolers that I have taught previously.



Friday, March 27, 2020

Teaching during Covid

 Found a website through a friend that let people volunteer to sign up and teach courses, so I signed up to teach a few classes.


Video game development (intro and hands on)

Hacking 101

Electronics Hacking (modifying existing electronics)


Unfortunately I can't share these videos as they contain kids faces/voices and don't want to violate their privacy, so here is an intro video I made to show off how good the engine can look.


In this demo, there's a powerpoint which is getting its data live from a google spreadsheet, then when the spreadsheet is done, the screen dissolves showing the "powerpoint" was in the unreal engine the whole time.




3D scanned action figure head

 I was testing some new AI models, and put together some tools that let me create 3d models from photos. This is "less accurate" t...