Jan 29


So I just watched The Incredibles because, you know, it’s a Pixar movie. And anything that Pixar makes is awesome. I mean, Pixar could make anything great. But anyways, one of the special features is about a deleted scene. What they were originally going to have was a pilot who flew the plane to the island, instead of Mrs. Incredible. The scene was basically the pilot flying, and then being shot down while the Incredibles escaped, and Dash asks “What about the pilot?”

Now, what would be totally awesome, was if this was a cameo for H. M. Murdock.

Yes. Murdock from The A-Team.

The rest of the movie could stay exactly the same, there’d be no need to change it. But at the end, there’d be a brief scene with all of the A-Team around Murdock in a hospital bed. And then Murdock asks: “So what’s the plan, Hannibal?”

Or something like that.

Jan 15

D-Bus tutorial finished

D-Bus tutorial finished. It should cover all major aspects of D-Bus, using both method calls and signals. I’ve tried to make it as clear as possible, but I’m afraid that it may not be quite clear. Hopefully it will be useful to people.

On a related note, this has caused me to greatly increase the features available on the website. BBCode now works(only for pages at the moment though). I do however need to make it more robust. At the moment it’s highly likely to break if bad input is introduced. In order to make something that looks good, I’m going to have to write some sort of tokenizer it seems. That way I can replace only certain instances. i.e. I want to make it so that each paragraph is enclosed by a <p> tag, but I don’t want that tag inside of code or quote blocks. Well, maybe inside of quote blocks, but definitely not code blocks. It makes it look weird.

Jan 13

D-Bus tutorial

So at work, we use D-Bus to allow our programs to talk to each other. However, when first learning how to use D-Bus, all of the information that we were able to find on the internet was either laughably out of date or otherwise useless. So I’ve taken it upon myself to create a good tutorial that shows you exactly how to use the D-Bus. Hopefully, you can find it helpful.

Note that it’s not done quite yet. I’m going to add more information on signals, plus sample code once I’m done. I should have time to finish it this weekend.

On a related note, the tutorial is the first page that uses my new page-generator. It’s basically the same as a new post, but it’s more static to the extent that it will stay on the left hand side under ‘navigate’. With this in place, we are coming up on a fully-featured CMS system. Of course, this is nowhere near ready to release, but the basic framework is mostly in place at this point.

Jan 11

RM5248: Now with comments(really!)

So I’ve finished up the comments feature of the website, and it appears to be working properly. Currently, I have it set to allow guests to comment as well. It seems to be rather good.

On a related note, viewing a post is now in its own separate page, as opposed to a parameter to index.php. I think that it looks a lot better that way.

More features to come soon.

Oh, I almost forgot: This website should be fully XHTML compliant; I have not checked the new pages, but up until this point the entire site is good. Standards checks are a good thing.

Jan 08

Adventures in PIC programming

Recently, I got a PICKit2 programmer from Microchip, for a project. I haven’t started, I’ve just been learning my way around the chip, using the included lessons. They’re somwhat lacking though, so from time to time I’ll post some (possibly useful) information on here.

Just so we’re on the same page, I’m using the second type of PICKit2 that Microchip sells, the DV164120.

Now, on to the possibly useful part. The first lesson is to turn on a single light, and the 4th lesson is to make those lights rotate around and chase each other. It took me a while to figure out exactly what was going on, so let’s go dive into lesson 1.

bsf STATUS,RP0 ; select Register Page 1
bcf TRISC,0 ; make IO Pin C0 an output

bcf STATUS,RP0 ; back to Register Page 0
bsf PORTC,0 ; turn on LED C0 (DS1)

goto $ ; wait here

This is relatively simple, so let’s try and set two LEDs on at a time. First, let’s make all of PORTC to be output. That code is given in Lesson 3. Plus, let’s set the second bit on PORTC to set the second light on.

bsf STATUS,RP0 ; select Register Page 1
clrf TRISC ;from lesson 3, set all of TRISC to output

bcf STATUS,RP0 ; back to Register Page 0
bsf PORTC,0 ; turn on LED C0 (DS1)
bsf PORTC,1

goto $ ; wait here

However, this doesn’t work! You’ll notice that only LED C1 turns on. Huh. That’s interesting, because we definitely set two bits, bits 0 and 1 to turn on DS1 and DS0.

Well, so what would happen if we were to, say give the bsf command a hex value that had both bits 0 and 1 set, like 0x03? Well, as it turns out, that will actually turn on DS4. What?!

The key here is that bsf is setting the [i]bit[/i] value. Basically, you give it a variable and you set the actual bit in that region. However, you can also load in a value to that region, which is what the rotate lesson does. Now, let’s look at the datasheet for the PIC, and look at the PORTC:

Notice how this is only 7 bits. These bits control which outputs are on at a time. We’re only concerned with the first 4 bits, because we only have 4 lights plugged into the PIC. Now let’s look at the relevant code for the rotate that sets what light to put on:

 bcf STATUS,C ; ensure the carry bit is clear
rrf Display,f
btfsc STATUS,C ; Did the bit rotate into the carry?
bsf Display,3 ; yes, put it into bit 3.

Basically, what this does is it clears the carry bit, which is in the STATUS register. Now, we rotate the Display variable to the right, after moving it into f. Let’s step through this from the starting point, where Display has the value of 0x8(note that the Microchip code has this as 0x08, however only one byte is relevant and needed, since PORTC is only 8 bits(1 byte) wide). The next part shows only the last 4 bits of the byte, as those are the only relevant bits for this example.

1000 ;display at beginning
0100 ;rotate display to right, in C this would be Display &gt;&gt; 1
;is there anything in the carry bit? no, don't put anything in bit 3
0100 ;display next loop
0010 ;display after rotate
;is there anything in the carry bit? no, don't put anything in bit 3
0010 ;display next loop
0001 ;display after rotate
;is there anything in the carry bit? no, don't put anything in bit 3
0001 ;display next loop
0000 ;display after rotate
;is there anything in the carry bit? yes, set bit 3
1000 ;display at end. repeat

Now back to our original question, which was how to set multiple lights to be on? Well, we need to do basically the same thing that we did for the rotate. We make a variable, and then we load the [i]variable[/i] with the hex value of what two lights we want on.

cblock 0x20

org 0
bsf STATUS,RP0 ; select Register Page 1
clrf TRISC ;set all IO pins C to output

bcf STATUS,RP0 ; back to Register Page 0
movlw 0xA ;1010 binary. Lights DS2 and DS4
movwf Display
movf Display,w
movwf PORTC
goto $ ; wait here

Simple once you understand it.

Jan 08

RM5248: Now with comments(almost)

I’m currently working on adding the ability to add comments to news posts. The framework is in-place, but I think that I need to re-work some of the website in order to make this more customizable. So, you can’t actually add any comments yet. I’m feeling rather lazy at the moment, and so I don’t feel like finishing it tonight.

So hopefully later this weekend. But because of what I want to do, it will take a little bit. Basically what I want to do is to make it possible to turn comments on and off, as well as have the ability to allow anonymous users to post comments. That’s something that I need to work on to allow maximum control over what is on the site, so that non-computer-savvy people can make a website for themselves and easily update it. This means that it would probably be a good idea to break out the viewing of individual posts into their own page, as right now that is all done thru index.php, and if I wanted to add more settings it would get very large and difficult to maintain. So, if I break it out into different pages I can make it cleaner.

I think that I am also going to look into re-working some of the SQL strings, making more use of PEAR to get values and insert values. Hopefully that will make it fully database-independent.