Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:07 04 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Micromite Library

     Page 1 of 3    
Author Message
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 01:11am 05 Dec 2014
Copy link to clipboard 
Print this post


This is a continuation of another thread that deviated into discussion of a Micromite code library. The relevant library posts have been transferred below. Glenn (Administrator) has advised that this is the only way to transfer posts from another thread.

  paceman said  
The MMBasic library on Geoff's site contains MMBasic Maximite programs, not Micromite, but I totally agree, a library for MMBasic Micromite code is needed. A couple of days ago, similar points were made in relation to a CFunction library in another thread, as below. It would be nice if both could be in the same place but that may not be workable for the "librarian(s)".

Greg

  paceman said  
  G8JCF said  As for a common CFunction library, I am more than happy to act as editor for CFunctions, and to provide a repository for them. If one refers to page 63,64,65 of the CFunction tutorial document, it describes how CFunctions could be published.

Sounds excellent to me, and having an "editor" that understands the process would be a major plus. What do others think, and I wonder what Geoff feels about this? There's already the MMBasic library that Hugh Buckle maintains on Geoff's website for the Maximite programs, but this would be a pretty different sort of animal.

  Quote  Perhaps I should open up a new thread specifically dedicated to the topic of CFunctions ?

I think a single thread on how CFunctions are produced, which could include discussion about the Tutorial, would be a good idea but not for the whole range of CFunctions. A single "CFunction" thread would have to have, sort of, subsections to cover the threads for different functions and would just complicate the board.

What might work to separate CFunction threads from the normal MMBasic threads (if that's needed at all) is to put, say (CF) as a prefix to the thread's subject heading as we used to do with (MM) or (DM) to designate a Maximite or Duinomite thread. That way people will immediately know that it will contain some "C" discussion. (Note: we don't use that MM/DM thing anymore because the whole issue has faded away, but Glenn introduced it for good reason a couple of years ago.)

I don't think we need to separate CFunction threads. There's a lot of information that's important in them anyway (or just plain interesting) for those who will never want to write one but probably will want to use them.

What do others think?

Greg
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 01:14am 05 Dec 2014
Copy link to clipboard 
Print this post

  G8JCF said   There are 2 kinds of Library

1) A Collection of things, eg programs, useful functions etc, and this is the kind of library established by Hugh Buckle. There is just 1 library.

2) A software library, eg LCD driver library, and this is the kind of Library which I think we need for stuff like CFunctions, and uMite code. There are many s/w libraries.

The distinction between 1) and 2) is that in 1), the librarian acts to collect, store and catalogue what is held in the Library. In 2), the Librarian makes sure that as well as Cataloguing, & storing items, the Librarian also acts to eliminate Name-Space clashes, standardises how the library is documented, standardises calling sequences/methods, standardises use of Global variables etc, ie more Editor than Librarian/Curator. The key purpose being that someone can then take a library off-the shelf, read the documentation, then add it to their program, and be confident that for example the library's use of a Global variable does not clash with the user's program's use of a Global variable, or that the library hasn't set OPTION DEFAULT INTEGER, when the user's program wants to set OPTION DEFAULT FLOAT, ie s/w libraries need to be as neutral as possible.

Question : Is this type of library facility, ie 2), required by the Community ?

Peter
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 01:15am 05 Dec 2014
Copy link to clipboard 
Print this post

  paceman said  
I'd certainly think so Peter but it would be good to hear other's opinions, especially Geoff's. Unfortunately I'm very much an amateur on software (hardware too for that matter) so my opinion here is from a limited base.

The "Library" subject should definitely have a separate thread anyway so I've PM'd Glenn (Gizmo), our Administartor and asked if he would move the posts from OBC's at 1:55pm on the 2/12/14 to your post above, into a new thread called "Micromite Library" or somesuch. I don't know how else to do this, or if Glenn is available at the moment to do it for us.

Greg
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 01:16am 05 Dec 2014
Copy link to clipboard 
Print this post

  G8JCF said   Hi Greg

As you say, it will be interesting to hear from others.

Peter
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 01:18am 05 Dec 2014
Copy link to clipboard 
Print this post

  Geoffg said   I very much agree also, we do need a library for Micromite programs and "snippets". I believe that it should hold all forms of code (MMBasic as well as CFunctions).

Hugh Buckle has done a great job of managing the Maximite library and it involves a lot of work. He has tested most programs and he chases up details (when necessary) from people who have submitted code. He also classifies submissions and indexes them.

For the Micromite it would be better if we had a more automated method where people could submit code along with a description and a classification and it would be automatically listed in a database. However, this would take a lot of work to setup.

To my mind any library would be worthwhile - even if it is not perfect.

I would be the logical person to maintain such a library but these days I am always running out of time and if I took it on I know that I would fail miserably. And I would prefer to spend my time polishing MMBasic.

So, we need ideas. Is there someone who wants to take on the job of maintaining a library? Or is there a better way to maintain a library without it being labour intensive?

Geoff
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 01:42am 05 Dec 2014
Copy link to clipboard 
Print this post

  TZAdvantage said   i could setup a page that can hold code samples and library functions.
it would be in a folder type structure where things could be categorized easily.
i would prefer that code would be posted through email to prevent spammers.
posting directly would be possible but that needs to be behind a login. the info can still be available for anyone, a login would allow trusted people to upload directly without moderation.

i already have something setup internally to store datasheets, mostly microchip and parts often used with microcontrollers. the structure can hold other info easily so it would not be too much work.
 
Gizmo

Admin Group

Joined: 05/06/2004
Location: Australia
Posts: 5116
Posted: 03:58pm 05 Dec 2014
Copy link to clipboard 
Print this post

I'm happy to host a document register on the main site if someone else can maintain it.

Couple of ways we could go. Either someone puts together a bunch of documents ( PDF preferably ) and files, with a separate index page, and they email updated files and index page to me, which I'll put online as needed, or I create a system from scratch where a administrator or two can log in and update the library themselves.

The first option would be prefered, I'm time poor at the moment.

Someone would have a document template, which can be edited and saved as a new page, and then saved as PDF to go online. They would send me the new/updated PDF and a updated index file. I would then upload it to the site and update the index page, so when someone clicks on a topic, it links to the relevant PDF or file.

I would like to put together a library app from scratch, but as I said I'm time poor. The biggest job with any new system is planning it, writing the code is the easy bit. If there is a existing system out there that would work for our needs, or someone can document how it should work, let me know and I can have a look at it.

Just an idea.

Glenn
The best time to plant a tree was twenty years ago, the second best time is right now.
JAQ
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 09:06pm 06 Dec 2014
Copy link to clipboard 
Print this post


Well, OK since I put the thread up maybe I should make a suggestion. There are several generous offers in the posts above and agreement that we need a Micromite library to hold both MMBasic programs and CFunctions.

Peter (G8JCF) has offered to be CFunction "Editor" and depositry (as per the 5th Dec, 9:14pm post above) and it seems to me that:
a) doing that would be a major job that no-one else is likely to offer to do.
b) he is best qualified and the logical person to do it.

Since Geoff, and I think all of us, would like all the Micromite code (MMBasic, CFunctions, snippets) in one place it would be great if Peter could also be the depositry of the "Basic-only" code. Whether he's happy to do this and under what conditions, I guess we're about to find out.

Hugh Buckle has put a lot of work into the Maximite MMBasic library as Geoff has pointed out "tested most programs, chased up details, classified and indexed submissions" and it's a big ask for Peter to also do this for the Micromite MMBasic programs. Maybe it could be "automated" a bit via a simple "submission" form or something to make it straight forward, though that obviously doesn't test things. If the form required a link to the TBS thread though that would help and if a user needed clarifications he could then contact the person that posted the program &/or information in the first place.

This thread probably needs to be aired a bit longer but what are the current thoughts?

Greg



 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 05:50pm 07 Dec 2014
Copy link to clipboard 
Print this post

Is this the kind of thing people have in mind (maybe hosted on TBS if possible)

MMBasicII Library

see OLEDI2CLib.bas for an example of a wee bit of 'Editorship" having been applied to minimise name-space clashes for Global Variables, and a slight moving around of the code so that the TestSuite code lines are placed at the end of the program for easy deletion. (would this kind of editorship be acceptable to Library contributors ?)

Peter
The only Konstant is Change
 
Gizmo

Admin Group

Joined: 05/06/2004
Location: Australia
Posts: 5116
Posted: 07:15pm 07 Dec 2014
Copy link to clipboard 
Print this post

Peter that's nice and neat, no fancy graphics or large files. Spot on.

The format is good because its easy to search, and easy to stick into a database at a later date. Once in a database, you can add a few nice features like order by column, better search, etc.

Might have to format the file names so less chance of getting duplicates, like SerialTxt_1_0.bas for the version 1.0 file

I would be OK to host something like that. I've recently found out my monthly bandwidth for the web site has gone up. It was only 30Gig originally which was often exceeded, but now its like 10 times that so I'm not as worried about exceeding my monthly limits.

Glenn


The best time to plant a tree was twenty years ago, the second best time is right now.
JAQ
 
Oldbitcollector

Senior Member

Joined: 16/05/2014
Location: United States
Posts: 172
Posted: 08:15pm 07 Dec 2014
Copy link to clipboard 
Print this post

+1 Peter

I can see this needing some "categories" at some point, but exactly what I envisioned as well.


My Propeller/Micromite mini-computer project.
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 08:33pm 07 Dec 2014
Copy link to clipboard 
Print this post

Hi Glenn

Thanks for the positive feedback.

Before you responded, I was thinking about a page-per-item approach - like man pages on Unix, where the index.html page simply had short links to the page for each item, so that the page could contain a lot more information. However that would of course increase storage size, and make database'ing the pages a bit more complicated, and materially increase the workload for the Editor/Librarian/Curator.

Being able to search and order by column would be really nice especially as the number of items grows.

Let's see what others think.

Peter
The only Konstant is Change
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 08:35pm 07 Dec 2014
Copy link to clipboard 
Print this post

@OldBitC

Just Added
The only Konstant is Change
 
Gizmo

Admin Group

Joined: 05/06/2004
Location: Australia
Posts: 5116
Posted: 09:59pm 07 Dec 2014
Copy link to clipboard 
Print this post

If you wanted to build the library in plain clean html, I can throw it in a iframe or use a bit of AJAX to display it within a TBS page. The TBS page "frame" would have the usual, like a menu and link back to main page, plus a couple of adverts but not in the middle area where the library content will be displayed.

Use tables, keep all links relative, and have a couple of sub folders, like "CFiles", "BASFiles", "PDF", etc. That will keep it transportable. Also ideally use a style sheet to keep the fonts consistent.

If the html is clean, its not to hard to import it at a later date into a database.

Or, if someone has MS Access and could use that to create the library in a table, then it would be easy for me to display that online. Displaying a access table is easy, its writing a web based administration back end that would take a bit of time to develop.

A Access database would mean we could jump straight into adding column sorts, filters, etc. The "librarian" would just need to email the updated table to me plus any new files.

Another option is to create the table in Excel, but a little more work to get set up right and longer to get a update online.

Glenn

The best time to plant a tree was twenty years ago, the second best time is right now.
JAQ
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 10:57pm 07 Dec 2014
Copy link to clipboard 
Print this post

Hi Glenn

The library code is all simple HTML and positioning is by tables, and indeed the data is held in folders/subfolders



As for the Database options, I could do an Excel file, but that's about as far as I could go - it's been too many years since I did dB work (30).


Peter
The only Konstant is Change
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10194
Posted: 11:02pm 07 Dec 2014
Copy link to clipboard 
Print this post

  Quote  would this kind of editorship be acceptable to Library contributors ?

I think this is an excellent initiative and excellent idea re the "test suite". Also this approach allows any variables used by the main program to be declared as LOCAL. Then the only variables defined as DIM would be true global variables

I don't think we need a separate cFunction library as per Grogster's thread. All cFunctions should be provided with a simple "test suite".

I'm happy to modify my code for inclusion as per any sensible set of library guidelines.

My biggest concerns for easy reuse are issues around OPTION DEFAULT, and OPTION EXPLICIT. I think OPTION EXPLICIT should be mandatory. In a perfect world I would prefer that code for inclusion would also be OPTION DEFAULT NONE. The only issue with this is the space that multiple "AS INTEGER" definitions take up. My recommendation would therefore be that only OPTION DEFAULT NONE and OPTION DEFAULT INTEGER are acceptable. FLOATs, which I think should become the exception, would then have to be explicity typed.


 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 11:26pm 07 Dec 2014
Copy link to clipboard 
Print this post

Hi Peter M

Phew, I wasn't quite sure how you would take my editing your code :) but I'm glad to see that you are up for producing 'neutral' libraries - thank you

Re Global Variables. ALL my programs have a SUB MAIN so that the only variables which are declared with DIM will be true Global Variables, ie why Dim and Local are so important to be used correctly. Also in Libraries, I always declare any Global variables as part of the Libraries INIT function, eg see I2CLCDLib and use the syntax Libname_ or Libname. to prefix such Global variables to minimise name space clashes

Re Library Function/Sub names, again, ideally all Function/Sub names in a Library should be prefixed with the Library name to mitigate against name space clashes, eg OLEDI2C.Init, I2CLCD.Init etc

Re Constants, MMBasic constants are always Global (Geoff isn't going to introduce Global/Local constants, we've already had that discussion ), so the potential for namespace collisions is extensive, again I would recommend that ALL library specific constants are prefixed with the Lib name, eg Const OLED.ScrnWidth = 128

Re TestSuite, this structure works well because it a) provides the programmer/author with a test bed with which to test out their code, b) demonstrates to the would be user how to use the library. Placing at the end of the code allows for easy delineation and subsequent removal by the end-user.

Re Option DEFAULT, this is going to need some thought, but IMHO, I believe that ALL library variables must be EXPLICITLY declared, eg Dim OLEDI2C.I2CAddr as Integer, and thus libraries should NOT declare Option DEFAULT. If user programs want to use the Option Default construct they would then be free to do so unconstrained by the Library

Re I2C, In general Libraries should NOT OPEN the I2C bus because other libraries might try to do the same, but more importantly User code could quite legitimately issue I2C Open constructs. I'm not sure how gracefully MMBasic handles an I2C Open to an already open I2C bus, perhaps MM.I2C could return the state of the I2C bus to permit libraries to skip I2C Open statement, and/or are there other techniques ?

Would it be OK with you if I complete the editing of your OLEDI2C library so as to produce a good example of how (I think) a library should be published, and then we can all debate around that example library ?

Peter


The only Konstant is Change
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10194
Posted: 11:56pm 07 Dec 2014
Copy link to clipboard 
Print this post

  Quote  ALL my programs have a SUB MAIN so that the only variables which are declared with DIM will be true Global Variables, ie why Dim and Local are so important to be used correctly.

Excellent approach, fully agree

  Quote  Also in Libraries, I always declare any Global variables as part of the Libraries INIT function, eg see I2CLCDLib and use the syntax Libname_ or Libname. to prefix such Global variables to minimise name space clashes. Re Library Function/Sub names, again, ideally all Function/Sub names in a Library should be prefixed with the Library name to mitigate against name space clashes, eg OLEDI2C.Init, I2CLCD.Init etc

Agree in principle of course. My only issue with this is space while loading the program. I don't think it is reasonable to expect everyone to use a pre-processor and a #define approach. My OLED routines already have to be "crunched" to load reliably.

  Quote  Re Constants, MMBasic constants are always Global (Geoff isn't going to introduce Global/Local constants, we've already had that discussion ), so the potential for namespace collisions is extensive, again I would recommend that ALL library specific constants are prefixed with the Lib name, eg Const OLED.ScrnWidth = 128

Agree other than the space issue

  Quote  Re TestSuite, this structure works well because it a) provides the programmer/author with a test bed with which to test out their code, b) demonstrates to the would be user how to use the library. Placing at the end of the code allows for easy delineation and subsequent removal by the end-user.

Absolutely agree this approach should be adopted.

  Quote  Re Option DEFAULT, this is going to need some thought, but IMHO, I believe that ALL library variables must be EXPLICITLY declared, eg Dim OLEDI2C.I2CAddr as Integer, and thus libraries should NOT declare Option DEFAULT. If user programs want to use the Option Default construct they would then be free to do so unconstrained by the Library

Agreed, therefore library routines and test suites should use both OPTION DEFAULT NONE and OPTION EXPLICIT to demonstrate that all vaiables are both fully defined and typed

  Quote  Re I2C, In general Libraries should NOT OPEN the I2C bus because other libraries might try to do the same, but more importantly User code could quite legitimately issue I2C Open constructs. I'm not sure how gracefully MMBasic handles an I2C Open to an already open I2C bus, perhaps MM.I2C could return the state of the I2C bus to permit libraries to skip I2C Open statement, and/or are there other techniques ?

This is easy to test for as per my usage in the DS3231 routines.

sub DSSettime
local clock$
local i
local i2clook=peek(WORD &HBF805000) AND &H8000
if not i2clook then i2c open 400,1000
i=rtcsetDS(clock$,time$,date$)
I2C write &b1101000,0,len(clock$),clock$
if not i2clook then i2c close
end sub



  Quote  Would it be OK with you if I complete the editing of your OLEDI2C library so as to produce a good example of how (I think) a library should be published, and then we can all debate around that example library ?


Absolutely

The only thing all this misses out is how to handle complete programs which users wish to contribute. I think there should be a section for full programs to be contributed that may or may not include library routines (which would be included separately).

Peter
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 01:23am 08 Dec 2014
Copy link to clipboard 
Print this post

Hi Peter

The issue of program size is a thorny one as always when it comes to the tradeoff of Readability & Quality vs Memory Footprint.

Personally I take the view that the code should be self-documenting, neutral etc, and that if a particular user needs to compress the size down, then that particular user needs to adopt measures such as using #define to replace constants and crunching long symbol names into short ones. If people don't use MMEdit, then crunching becomes a real tedious exercise, whereas with MMEdit, crunch happens automatically and transparently every-time one downloads code to the uMite.

Re Option Default None and Option Explicit - these statements should be used by the library developer to ensure that their code is as defect free as possible, eg usually declared in the TestSuite, but should not be present in the Library itself, thus granting the end-user "the maximum freedom to make a mess of things !" - I jest of course, but the library should not try to impose a particular coding style on the end-user even if it would be in the end-user's best interests

Re I2C, EXCELLENT, I'll give that idea of yours a whirl, even better perhaps write a CFunction IsI2COpen

Thanks for the permission, hopefully you will like and approve of the results.

As for whole programs, I don't see why that wouldn't just fit in, I think we'll have to change the Type column to have 3 values, CFunc, Lib, Prog ?

Peter
The only Konstant is Change
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 03:00am 08 Dec 2014
Copy link to clipboard 
Print this post


Wow, that all seemed to work , thank you very much gents, especially obviously Peter, Peter and Glenn. You all seem to know a blo...y site more about this than me so I'll stand clear!

Couple of things though - of course , written in the Royal "we":

- I agree we definitely need to cater for full programs.
- Will we also cater for MMBasic subroutines.
- What about .JPG files? There's a few of them in the MMBasic library and they can be handy but they might be an issue for Glenn.
- Can we include links to the appropriate threads - assuming there is one which is usually the case.

Thanks again and over and out

Greg
 
     Page 1 of 3    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025