What Have You Done Today - (Computer Version)

  • Thread starter tlowr4
  • 4,142 comments
  • 258,330 views
Yeah, I've heard it can take up to an hour to compile the code for the Descent source port, seeing as it'd take me about a quarter of that time to download it on my PC I don't think I'll bother...
I wonder if there's a cross-compiler for the BCM2835 (or pedantically the ARM1176 CPU) so you could compile it or other large projects on a desktop/laptop then just copy the compiled binary over to the Pi. Actually I'm sure there is; just a question of finding it. I was amazed to find that GCC is installed by default on the Pi; figured I'd have to install it myself if I wanted to do anything in C.

As for heatsinks, they're typically just tiny self-adhesive things, not much more to say about them; I bought mine from here but I've seen a few places selling more or less the same thing. I've got a model B Rev.2 (with the P5 and 6 headers and GPIO 27 instead of 21, for whatever reason), and it hit 48C today doing absolutely nothing at all. In the shade, too, though it has been kind of warm today. That is if you're out of the wind and rain, anyway.

What are you using for a temperature sensor? Sounds like it could be a nifty thing to have.

I got the enclosure for the SSD, and copied the hard drive over to the SSD. It turns out, though, that the Raspberry Pi doesn't supply enough current through its USB ports to power the SSD like I thought/hoped it would. So I plugged it into a USB hub and that works fine. I might get a USB 3.0-capable hub, that way I can power the Pi as well off the hub and achieve my aim of running the thing off a single power supply.
 
What are you using for a temperature sensor? Sounds like it could be a nifty thing to have.

You have two choices:

/opt/vc/bin/vcgencmd measure_temp

Or:

/sys/class/thermal/thermal_zone0/temp

The latter gives you the measurement in millicelcius, and that's how I'm getting my data (since I know how to read files with Python but not how to get the results of a command into Python). If I had my Pi plugged in I'd post the code for the small program that reads the file, converts the string to an int then 'breaks out' each digit into individual array cells, but a) I don't have it plugged in and b) it's really, really simple anyway, like ten lines or something.
 
You have two choices:

/opt/vc/bin/vcgencmd measure_temp

Or:

/sys/class/thermal/thermal_zone0/temp
Ah, cool! I didn't know about those; figured I'd have to pick up some sort of thermal sensing device, etc, etc. That makes it too easy!

The latter gives you the measurement in millicelcius, and that's how I'm getting my data (since I know how to read files with Python but not how to get the results of a command into Python). If I had my Pi plugged in I'd post the code for the small program that reads the file, converts the string to an int then 'breaks out' each digit into individual array cells, but a) I don't have it plugged in and b) it's really, really simple anyway, like ten lines or something.

Actually I'm finding that
Code:
$ cat  /sys/class/thermal/thermal_zone0/temp
works just fine, and mentally convert the 41160 output to 41.16 degrees. Not sure why you'd want to read a string into an int then extract each digit into an array element especially since strings are, at heart, arrays of chars or at least easily converted into such.
 
Not sure why you'd want to read a string into an int then extract each digit into an array element especially since strings are, at heart, arrays of chars or at least easily converted into such.

Very long story short, because I have to multiplex the display (it's a DIP-12 4-digit display IC, 8 pins are bussed amongst the four digits' segment anodes, the other four are the digits' discrete cathodes) I have to synchronise what the two 595s are doing and to do that I need to be able to basically tell it that 'when 595A is grounding the leftmost display's cathode, 595B should push the leftmost digit to the anodes' and so on so that the correct digit shows the correct place value. In addition to that, I have to use the integers as array pointers (not sure if that's the right word) to basically map the values to the correct 7-seg hex, since obviously if I tell a 595 to just output '4' it'll give me 0000 0100 when I need 0110 0110 (0x66 or whatever the sum of 64, 32, 4 and 2 is).

So, if there is a shorter way of converting (for example) the string '41160' into array = [4, 1, 1, 6] than:

Code:
digit = int('41160')
thousands = digit / 10000
array[0] = thousands
hundreds = (digit % 10000) / 1000
array[1] = hundreds
tens = (digit % 1000) / 100
array[2] = tens
ones = (digit % 100) / 10
array[3] = ones

I'd love to know what it is! I'm just reusing old code that has worked for me before.

Edit: I did actually find a better way of writing this, and I think I've just worked out a better way while typing this sentence, I guess you can probably do int(array[number]) so even if the array was full of chars it wouldn't really matter. I can't be bothered to test this right now, though.
 
Last edited:
I have no idea where it came from but my work computer magically had Conduit on it this morning when I got in. :odd:

It has now been remedied.
 
Well, my Raspberry Pi temperature monitor is working, though I'm reluctant to call it finished just yet. It displays the temperature (which updates every three seconds), but:

- I can't start and stop it at will,
- I had to make a separate program to control the 'polling' rate because I just wanted it to work soon rather than work properly so I skipped the interrupt service routine it'll eventually need,
- If I try to run it in the background, when I kill it I'm (predictably) left with stuff displayed and the GPIOs stay reserved because the cleanup functions aren't allowed to run.

So there's still some work to be done, but for now I think I'm happy to let it run whenever the Pi is on... That is if the current requirements are very low. I have no idea what the operating current actually is right now but I'm going to see how low I can go with the LED current, I think it'll be pretty low. I worked out that I should be using 390R so I used 470R instead and they're still easily legible.

Picture!
s0pH9k7l.jpg


I think the next step should really be to fix the program, but instead I'm going to get some 90 degree 2x4 male and female headers to solder P5 on from underneath (it doesn't really fit where it is now) and make a combination temperature display/camera module mount out of stripboard for the bottom of my Pi. Or maybe I'll use the PCB etching stuff (etch resistant pen, ferric chloride and a sponge) I got the other day and do it 'properly'.
 
Started losing a hard disk in my raid array over the weekend. The failure was soft and not terribly easy to diagnose. A new drive should arrive tomorrow to replace it. The old drive is still under warranty, so I guess my raid array will be stepping up to 12TB total.
 
What have you installed recently?
I downloaded some software for construction cameras but that was from the camera manufacturer's site (axis.com) so I didn't, and still wouldn't, think twice about it. Besides that, nothing of note.
 
Very long story short, because I have to multiplex the display (it's a DIP-12 4-digit display IC, 8 pins are bussed amongst the four digits' segment anodes, the other four are the digits' discrete cathodes) I have to synchronise what the two 595s are doing and to do that I need to be able to basically tell it that 'when 595A is grounding the leftmost display's cathode, 595B should push the leftmost digit to the anodes' and so on so that the correct digit shows the correct place value. In addition to that, I have to use the integers as array pointers (not sure if that's the right word) to basically map the values to the correct 7-seg hex, since obviously if I tell a 595 to just output '4' it'll give me 0000 0100 when I need 0110 0110 (0x66 or whatever the sum of 64, 32, 4 and 2 is).

So, if there is a shorter way of converting (for example) the string '41160' into array = [4, 1, 1, 6] than:

Code:
digit = int('41160')
thousands = digit / 10000
array[0] = thousands
hundreds = (digit % 10000) / 1000
array[1] = hundreds
tens = (digit % 1000) / 100
array[2] = tens
ones = (digit % 100) / 10
array[3] = ones

I'd love to know what it is! I'm just reusing old code that has worked for me before.

Edit: I did actually find a better way of writing this, and I think I've just worked out a better way while typing this sentence, I guess you can probably do int(array[number]) so even if the array was full of chars it wouldn't really matter. I can't be bothered to test this right now, though.
Ah, okay, makes sense now; I've worked with multiplexing seven-segment displays before.

As for the code, here's how I'd do it in C:
Code:
strcpy( input, "41160" );

for ( i = strlen( input ); i; ; )
{
    i--;
    digits[i] = input[i] - 0x30;
}

This will set digits[0] to the value 4, digits[1] and digits[2] to the value 1, digits[3] to the value 6, and digits[4] to the value 0; you can ignore whichever you don't need. Note this will work with any arbitrary number of digits. A couple caveats: input and digits have to be declared large enough to hold the longest string of digits you'll be using, and the routine does no error-checking (ie, checking that chars in the input are in fact numeric digits).

This could be done in PHP similarly. However PHP has a native string data type whereas C doesn't; strings are really arrays of characters. PHP also automatically does ASCII/UTF8 char to numeric conversion; so we wouldn't need to subtract 0x30 from the characters. So the second line of the loop would look like:
Code:
    digits[i] = substr( input, i, 1 );

Another approach would be to convert the string to an int up front like you're dong now, then extract the digits right to left by looping through these two statements:
Code:
    digits[i] = input % 10;
    input /= 10;

- I can't start and stop it at will,
- I had to make a separate program to control the 'polling' rate because I just wanted it to work soon rather than work properly so I skipped the interrupt service routine it'll eventually need,
- If I try to run it in the background, when I kill it I'm (predictably) left with stuff displayed and the GPIOs stay reserved because the cleanup functions aren't allowed to run.
Very cool! (no pun intended).

You can write a signal handler for SIGABRT to call the cleanup routine before exiting. When you type "kill process-id" or "killall process-name" it sends the SIGABRT signal to the process and the default signal handler for SIGABRT is basically to terminate the program more or less gracefully. Type "man kill" and "kill -l" for more information.
 
(no pun intended)

A GTP Premo who does not intend puns? I will not hear of it!

I revised the stuff with the array (sorry, list) to simplify it a whole lot:

Code:
file = open('/home/pi/scripts/temperature','r')
digits = list(file.read())
file.close()
del digits[3:]
if digits != []:
    digits.append(10)

for x in range(0,4):
    writenumber(displaycathode[x])
        if digits != []:
            if x == 1:
                writenumber(letterrange[int(digits[x])]+1)
            else:
                writenumber(letterrange[int(digits[x])])
            writeout()

There's a little bug related to the fact that I have a separate program doing the data updates independently of the main program, which is that if the data is sampled when the other program is writing to the file it returns nothing, so when the program was indexing digits later on the program would crash with an index out of range error hence the two 'if digits != []' statements. Also I'm appending the list with '10' because it seemed much more elegant to add an eleventh term to the 7-seg hex list to display a C on the display than to have 'if x == 4: write 0x9C' or whatever it would be tacked on at the end. When I can be bothered I might ditch the displaycathode list and just do it with an if statement and bit shifting instead, just to save the few bytes of memory for good form... Oh, yeah, and integrate the other program into this one, and have a toggle button for the temperature display. Then later I might use the last four bits of the second register as a 4-bit fan speed controller hooked up to an external DAC and a MOSFET or something, I haven't give it any thought so far, really.
 
Not exactly something I did to my computer today, but something I ordered for it - 16GB Corsair Vengeance memory kit. Will eventually fully replace the 8GB set I currently have in my computer as that is going in a gaming HTPC when I get around to building one, but in the meantime I'll be running 24GB total :D
 
Today I got around to playing with UbuntuStudio, a couple of weeks ago I saw the distro and realised it bundled several things I like to us/would like to use more. Except they all work... I've been meaning to get around to Linux properly for years and my attempts at using it have been, well, annoyed mostly.

Best download I ever made, these things being relative. And internet guides are better than what they was.

I'd go so far as to say that for the first time I'd genuinely consider Linux as my main OS at home. Crikey.
 
After having it working in Windows 8 and being disabled in 8.1, I've just spent the last hour and a half trying to re-figure out how to not have it automatically sign in the last user. It really, REALLY shouldn't be this difficult to not sign into my kids' account by default but at least there's a work around.
 
I have two questions, but first, a brief back story:
About two weeks ago we had a power cut and my PC refused to boot afterwards. I removed the boot drive (a Crucial M4 128GB SSD I bought towards the end of 2011) and connected it to my MacBook Air with a USB enclosure, it instantly mounted and I was able to access my files and all that. I put it back in the PC and all was well. Last night we had another power cut which left my PC unable to boot again. I repeated the process but the SSD didn't mount for about ten minutes. I'm taking this as a sign that the SSD is pretty much on its last legs - it's getting a bit old and liable to pop even without all the power cuts we get anyway - so I'm looking to order a Samsung 840 EVO 256GB to replace it.

The questions:
- If I clone my current SSD with OS X's Disk Utility, would I be able to restore a formatted hard drive with that image so that it's an exact copy of the SSD? I realise the best answer to this is probably for me to just try it but it'll take some time to even find a spare hard drive, so I just wonder if anyone has done this before and can give me a 'yes' or 'no'.

- If I want to start fresh (which I actually really do) and decided to give Windows 8.1 a trial run, instead of burning the .iso onto a DVD (I don't own a DVD burner because I'm not a dinosaur), could I clone it onto a spare hard drive (again with OS X's Disk Utility) and boot from that to install it onto the new SSD?
 
The questions:
- If I clone my current SSD with OS X's Disk Utility, would I be able to restore a formatted hard drive with that image so that it's an exact copy of the SSD? I realise the best answer to this is probably for me to just try it but it'll take some time to even find a spare hard drive, so I just wonder if anyone has done this before and can give me a 'yes' or 'no'.
I can only answer this question with an "I don't know" but I would like to make a comment here: If you make a bitwise copy of the SSD onto another medium it should work, and should show up as a 128GB drive which will have to have the partition size(s) adjusted. I have no idea if your OSX utility can do it, but the standard unix "dd" command can clone drives this way; Incidentally your Raspberry Pi implements the "dd" command.

- If I want to start fresh (which I actually really do) and decided to give Windows 8.1 a trial run, instead of burning the .iso onto a DVD (I don't own a DVD burner because I'm not a dinosaur), could I clone it onto a spare hard drive (again with OS X's Disk Utility) and boot from that to install it onto the new SSD?
Alternatively, burn the .iso onto a USB flash drive, SD card, or some such.
 
I can only answer this question with an "I don't know" but I would like to make a comment here: If you make a bitwise copy of the SSD onto another medium it should work, and should show up as a 128GB drive which will have to have the partition size(s) adjusted. I have no idea if your OSX utility can do it, but the standard unix "dd" command can clone drives this way; Incidentally your Raspberry Pi implements the "dd" command.


Alternatively, burn the .iso onto a USB flash drive, SD card, or some such.

I think Disk Utility is just a GUI for dd, I really don't know though. I looked into some of the things you can do with dd with OS X's terminal and it seemed pretty much the same, but Windows is still a complete mystery to me so I can never tell if things will work. As for burning the .iso to a USB flash drive, I wasn't sure if I could boot from a USB device but now that I think about it, surely a PC built in 2011 - one with UEFI, which seems to be a good thing? - would have that functionality.

Side note: I ordered the 840 Evo 256GB. My PC is working fine now (apparently I just had to get the drive to 'wake up') but then I saw this... Seems things have moved on a little in the last three years!
 
As for burning the .iso to a USB flash drive, I wasn't sure if I could boot from a USB device but now that I think about it, surely a PC built in 2011 - one with UEFI, which seems to be a good thing? - would have that functionality.
I'd certainly think so. Incidentally Win32 Disk Imager is a very good utility for burning .iso images onto flash media. It would also be a good idea to format the flash drive/card with SD Formatter beforehand as well. Don't use the native Windows formatting tools on flash media. I use both of those tools a lot. Note that in spite of the name, SD Formatter works with USB flash drives too.

Side note: I ordered the 840 Evo 256GB. My PC is working fine now (apparently I just had to get the drive to 'wake up') but then I saw this... Seems things have moved on a little in the last three years![/QUOTE]
Heh, indeed they have. I paid sixty five dollars for the 120GB SSD I put in my RasPi; three years ago that would have been more than double the price and half the speed.
 
I got my new SSD (on a Sunday, on a bank holiday weekend, when the estimated delivery was the 27th?), currently downloading the Windows 8.1 enterprise evaluation with a view to flashing it onto a USB stick for installation. Then I figured the ultimate compatibility test is to get GP Legends running on it so that's the next order of business (after all the drivers and such - ugh), though even if that fails I might get a 128GB 840 Evo for a Windows 7 or even XP install for old stuff that doesn't work in 8.1.

Edit: Well, cloning the 8.1 trial install ISO onto a spare hard drive didn't work. Well, it did, but my PC doesn't want to boot from it. Now I'm cloning it onto a USB flash drive instead so hopefully that'll work, if not I suppose I'll have to ask one of my dinosaur friends if I can burn the ISO onto a - shudder - DVD.
 
Last edited:
I gave up on Windows 8.1 due to a combination of not being able to make a bootable volume and the possibility that Windows 9 will be upon us soon, so I've spent the day so far reinstalling Windows 7 instead. Naturally I'm having trouble with a few things:

- Freetrack won't run because I don't have DirectX 9.0c installed, DirectX 9.0c won't install because of reasons (I presume),
- Saitek's Smart Technology thing I need for my X52 Pro wouldn't install properly and now won't uninstall properly,
- Logitech's Gaming Software 5.10 for my G27 won't run because of something to do with a side-by-side configuration,
- The Asus Xonar DX driver software refuses to 'see' that the card is installed (really tempted to just bin the card, though!),
- Windows Update isn't really working as it only downloads a few things each time I run it - no great surprise there.

So it's all fun. With regards to my Raspberry Pi, yesterday I started trying to program it to add a virtual keyboard which would make way for a physical keyboard, it was all going quite well until I tried to make it work with variables because the bit I need to vary is an attribute of an argument of an attribute of a variable... It really didn't like that. To be more specific, to get it to type a single character the simplest program is:
Code:
import uinput
device = uinput.Device ([
    uinput.KEY_A
    ])

device.emit_click(uinput.KEY_A)

To get it to interface with an actual keyboard matrix I'd have to make KEY_A into a variable that could be any key but I couldn't work out how to make it do that. The library's code is even more cryptic so I'm not having much luck with that either. I'm not convinced the benefits this would bring (i.e. using the Pi to interface with the keyboard rather than an Arduino Leo/Micro as a go-between USB HID interface) are actually worth all this.
 
Well it turns out my PC was dying so thats gone to get looked at (the guy reckons its a PSU problem). So what I have done today is get my old PC out so I still have something to do.

Its killing me though I have gone from an SSD powered beast that is ready for use after boot in about 40 seconds to this bag of crap thing. its been on 15 minutes and it still had to stop and think just then when I got an alert.
 
Today I received the accoutrements necessary to use the 'spare' hard drives I have lying around (320GB 3.5", 1TB 3.5", 120GB 2.5" and 128GB SSD) in my PC, so I'm going to finally get around to converting my ripped DVDs to m4v or mp4 so I can stream them to various devices around the house. I also got a Raspberry Pi B+ so I think my old Pi will be used as an iTunes home sharing server that can be on 24/7 (hopefully, I'm not sure how good the software is) while the B+ will end up in a sort-of laptop thing I'm sort-of making very, very slowly.

So right now I'm moving stuff around so I can format the 1TB drive, then move everything onto that and format everything else. It's slow going even though I have a USB 3.0 HDD dock, but then I am transferring >100GB or so from a hard drive to my laptop, then from the laptop to another hard drive. Much fun. I wish Windows 7 could read HFS+ format, it would be so much faster.

Edit: I just transferred my 5.1 speaker setup (via a Sony DAV-DZ260 home cinema thing) from my Mac to my PC. Then I realised I forgot to put my music on the 1TB hard drive after I formatted it, so that's a shame. Can't be bothered to fix it now, either.
 
Last edited:
...while the B+ will end up in a sort-of laptop thing I'm sort-of making very, very slowly.
.

Have you made any progress with it since you last updated the thread for it? I'm very interested to see how it turns out. 👍
 
Have you made any progress with it since you last updated the thread for it? I'm very interested to see how it turns out. 👍

I've made progress in that I completely binned that idea because it wasn't going to work - I couldn't find out what the LCD panel number was without completely destroying it (which was kind of a big deal), but even if I had I'd need a 12V 4A supply to drive it which was going to be quite challenging to fit inside the case, the trackpad refused to work at all, the case was most likely going to be too small... Basically, all I could really take from the donor laptop was the keyboard, fan and speakers. Since then I've been doing other things but I've worked out how to interface the keyboard with the Pi directly - though I have yet to actually make that, I've got some 0.3W audio amplifiers to drive the speakers from the old laptop and I've got a display that'll work. I need to design and make a case (which will cost money that I can't really justify spending on this right now, though I think I'd use acrylic and make my own bending machine to form it), work out the other features I want it to have - Wi-fi, a powered USB hub for bus-powered USB storage devices, maybe an SSD or hard drive. Oh and a battery, which is going to cost more than the Pi itself because I don't think it's really worth doing if you use anything with less than 10,000mAh and I'd ideally like a 20,000mAh pack. So in other words I've reached the point most of my projects reach before they stagnate and I get sick of thinking about them, which is the point where I have to buy things.
 
Back