gnupic: Re: [gnupic] is OO any use?
Subject:
Re: [gnupic] is OO any use?
From:
Iain Dooley ####@####.####
Date:
19 Aug 2005 04:34:03 +0100
Message-Id: <43055678.9020203@iaindooley.com>
David McNab wrote:
> Hi,
>
> This is not a troll, so please forgive me if it comes across as such.
what is a troll?
> What I'm asking here is - is there any real practical value to be gained
> from supporting OOP in a PIC runtime environment?
when i recently did a project on 18f, i wrote the entire thing in
assembly, and i took a very OO approach to it. because all C functions
are automatically declared external in C18, and because a software stack
is used rather than having any encapsulated memory allocation, i felt as
though the principles of OO were not really available developing in C.
when i was developing in assembly, i used a methodology that was quite
similar to OO in C++. i had an interface file which defined all external
memory locations and sub routine names, and then i had what i termed
'call macros' that were macros that accepted arguments and then placed
them in memory locations specific to each module. this meant that i had
the convenience of a 'calling' interface to my module subroutines, but
didn't have to use the software stack. there was no inheritence,
polymorphism etc. but by defining modules that provided interfaces to
all the basic hardware on the PIC through subroutines with predefined
constants used to set values in configuration registers, a certain level
of abstraction was maintained.
i found this to be a great asset in the project. i was working with four
others, and we were all developing completely different modules and just
defined the interfaces between these modules. we integrated on the last
day before the project was due virtually hassle free.
i suppose this wasn't object orientation as such, but it felt very
object orientated (quite literally, in fact, because as our basic
library of functions were stabilised we put them in object files and you
just required whatever modules you needed), and i definately think that
there is a place for object orientation on the PIC.
for example, one of the modules i developed was the UI module. i used a
function table to respond to numeric key presses by writing directly to
the program counter. i abstracted the modules for interpreting the
commands, so that the same functionality was available from the keypad
digital I/O or via hyperterminal in a serial interface. i then
abstracted the user feedback to another module that determined whether
information should be sent out via serial to to the LCD display module.
i think it would be powerful to have this as a true OO abstract UI
class, into which you can plug in different input interfaces, function
tables, functionality and display devices to give a highly rapid and
flexible user interface development environment that could be reused for
virtually all PIC projects worldwide.
iain