New Year’s Resolution: Finish What I start
I’m definitely one of those people who have ADHD when it comes to starting and completing projects.
My problem is that everything I see looks too exciting and I want to start it right away, and also that I feel increasingly like…I need better time management essentially, therefore my new years Resolution is to finish a project before starting a new one – I’m 2 months late, I know, but better late than never. I have an arduino necklace on hold:
grid wars and boiling point on long term hold because of uni work, parts of the tinymatrix project (by parts, I mean a coincell holder, some wires, a lot of LED matrices and a lot of resistors – if anyone wants some resistors, I will sell them to you for 10p per resistor when I bought them for less than 2p each…) but no actual microcontroller or programmer, and then a list of other stuff I want to do. Right now, my project is still my Snake game in Python (heheh, terrible pun, get it…python sna-yeah. I know. it’s bad.) especially since next weekend is the Raspberry Jamboree.
This project varies greatly – I had a base code which I completed and tested, and appears to work well. Note when I say “I completed”, I stole a method from Adafruit because I don’t know enough python and there’s some parts where I will eventually learn it, but not right now. Anyway, being from the world of Object Oriented languages, I decided to move that along and make objects – so I have a serial input object, and then a joystick child class because I want it to read 2 channels and then a select digital channel when I eventually wire that part up properly.
class ClassName(parentClass (put in object if you’re not planning on making it a child of anything)):
def __init__(self, any params we need):
initialization code here, like ClassName.param = param
if we have a parent class, we will also need to go like parentClass.__init__(params here)
and then initialize an instance by:
ObjectName = ClassName(params)
and that’s really all there is to it. You have to remember to include “self” as a param for every method but do not have to pass it in if you are, for example, calling ObjectName.GetMember() – python will intrinsically pass the object in for you – and if you’re calling a method from inside the class e.g GetMember it has to be prefixed by “ClassName.”, but other than that, it seems very clean.
Oh also, importing your other python files is quite easy:
I believe it has to have been compiled first; if you want to avoid prefixing classes pulled from the file with the file name, you also need:
from py_file import py_class1, py_class2
My problem now is that my object bit…heh…the readings are a bit dodgy, don’t really understand why. [my code's fault, not the object functionality] I may end up just reverting to my old code and then importing it…we shall see.
Annoying thing is I started on raspbian wheezy, which the wifi is not currently functioning properly, so my original codes are on there and without internet it is difficult to get them transferred. I now use Occidentalis, which is the distro created by Adafruit – I highly recommend it, although it’s best headless because with all the peripherals plugged in – a: it runs slower; b: the wifi will get an IP, but will not hold onto a connection long enough for you to really do anything with it. Github is definitely the easiest way to write code and send it between your pi and main computer, although I usually use geany over VNC, it’s purely because to transfer some code off I had to write it out on my laptop and didn’t fancy repeating the process to get it onto Occidentalis.
Once I have the joystick fully working, my next challenge is working out how serial works and shift registers…still not entirely sure I wired it up properly. Or why when I plug certain things into certain bits the lights flash up when I haven’t told them to…
Oh yeah. besides all that, I have coursework due in. and a Spanish listening test on thursday. Whoopdidoo.