How to silence the fully charged battery chime on your Android phone

silence-of-the-android

Oh Hallelujah! I finally figured out what to me seems like the easiest solution to disability the sound that is played when my Android phone is fully charged. Since this is my only telephone I don’t want to turn all the sound off at night in case of an emergency call coming in. But it wakes us up when the battery is fully charged by playing an audible chime sound. I’ve looked for a solution many times but never found one. What I came up with is to replace the audio file with an edited one that only plays silence.

If you have a rooted phone and know what you’re doing, give this a try. Of course, I’m not responsible if your device is damaged or otherwise harmed in this process.

I’m working on an LG Optimus L9 (the P769 variant) phone running Jelly Bean. Find the sound file and copy it to your computer:

adb pull /system/media/audio/ui/FullBattery.ogg .

Now edit the file to be silence. I called my new file “FullBattery_silence.ogg”. If you don’t want to edit your own file you can download mine.

adb push FullBattery_silence.ogg /sdcard/.

Log into adb shell

adb shell

Remount the system directory so that it is writeable

mount -o rw,remount -t ext4 /dev/block/platform/omap/omap_hsmmc.1/by-name/system /system

I figured this out by looking at what is listed when the command “mount” is typed (color added for your convenience):

mount | grep /system

(this is the output):
 /dev/block/platform/omap/omap_hsmmc.1/by-name/system /system ext4 ro,relatime,barrier=1,data=ordered 0 0

Get root and change directories

su
cd /system/media/audio/ui/

Copy the file to this directory

cp /sdcard/FullBattery_silence.ogg .

Change the name of the original file

mv FullBattery.ogg FullBattery_backup.ogg

Rename your replacement file

mv FullBattery_silence.ogg FullBattery.ogg

Set the /system file to read only and exit:

mount -o ro,remount -t ext4 /dev/block/platform/omap/omap_hsmmc.1/by-name/system /system
exit
exit

That does it. The sound will still be played but now it’s just a silent audio file which won’t wake you up at night!

I’m going to be on NPR Science Friday this week

npr-science-fridayI’ve been invited as a guest on NPR Science Friday this week! This is really exciting. The show is a high caliber nation radio program about all things science.

The topic of discussion will be summer science projects for kids. I’ve got a few really top-notch projects that have been my favorites over the years so I hope you’ll tune in to hear about them. You can find programming information for your local National Public Radio station here. My segment should start at about 2:15pm Central time.

Python Gotcha: When copying a list ends up biting you

I recently spent a couple of hours chasing down one single bug in my program that was wreaking havoc on the output. I have been working on a QR Code generator and one of the final steps before making the code is applying eight different types of masking to the list of pixels in order to see which one produces the code which will be most readable to a device. I could apply one mask without issues, but applying the second mask — through looping or by copy and paste of the commands — produced erroneous data. It turns out the problem is in how I was (or actually wasn’t) making a copy of the list.

Let’s start with a simple example list:


test_list = [
 ['first member', 1, 2, 3],
 ['second member', 4, 5, 6],
 ['third member']
 ]

What does this look like to you? To me it looks like a list of lists. It’s a convenient data structure that I use all the time. Let’s make a copy of it:


list_copy = test_list

Now, to see what’s actually going on we need to look at the id of each variable (I defined a small function to give us a nice output for this step):


def disp_id():
 print "test_list id: ",id(test_list)
 print "list_copy id: ",id(list_copy)

>>> disp_id()
test_list id: 139936602407640
list_copy id: 139936602407640

I didn’t make a copy of the list, I simply assigned a new variable to the same list object. Remember that, it’s going to come back in just a minute. There are a couple of different ways to make a new copy of a list. Here’s the one I use because I think it’s the most readable:


list_copy = list(test_list)

Now let’s look at the ids of each of the lists :


disp_id()
test_list id: 139936602407640
list_copy id: 139936410105400

The lists now have different id numbers which means they are actually different list objects.

Now here’s the gotcha:

What happens if I change some data in the first list and print out its contents as well as the second list’s contents?


test_list[0][0] = 'big trouble'

>>> test_list
[['big trouble', 1, 2, 3], ['second member', 4, 5, 6], ['third member']]
>>> list_copy
[['big trouble', 1, 2, 3], ['second member', 4, 5, 6], ['third member']]

This behavior is very hard to find if you don’t know what you’re looking for. It’s caused by the fact that the Python doesn’t see this as a list of list, it sees it as a list of list objects. When I copied the original list using the list() function Python made a new list for me, but populated it with the ids pointing to the objects inside (in this case each object is a list but you will have the same problem with your own objects). There are a couple of ways to solve this but the best is to use copy.deepcopy():


import copy

list_copy = copy.deepcopy(test_list)

>>> list_copy
[['big trouble', 1, 2, 3], ['second member', 4, 5, 6], ['third member']]
>>> disp_id()
test_list id: 139936602407640
list_copy id: 139936410105040

test_list[0] id: 139936410106048
list_copy[0] id: 139936410172664

Now you can see that the data in each list is the same, but the id pointing to the objects is different. You can safely change anything inside one list without affecting the data in the other.

How to make an upholstered headboard

07-final-installation

Making your own upholstered headboard doesn’t take much time, skill or money. I’ll show you how to go from nothing to fully installed in less than a day. Join me after the jump for a step-by-step explanation and a build video. Our headboard is for a queen sized bed, but making one for a King Size, Double, or Twin Sized bed will be just as easy.

Continue reading

Level converter lets you use 5V hardware with 3.3V ARM chips

I’ve got a fair amount of equipment on hand for prototyping 5V projects. The problem is that I’m working mostly with ARM chips these days and that stuff is just sitting around gathering dust. I recently hit Mouser and started looking for what’s available when it comes to level converters. Most of them are either one-way, or have a pin that needs to be toggled to switch direction. But I found one chip that is bi-directional and sounds fantastic. TI makes the TXB0108. It’s got eight channels, one side of the chip works with 1.2V to 3.6V, the other side works with 1.65V to 5.5V. This is perfect, and will even let me prototype with some of those 1.2V EEPROM chips I bought by accident. Join me after the break to see the breakout boards I made and a quick test of the hardware.

Continue reading