is there a way to save a text or csv file from AM ?

Peer support for Air Manager desktop users

Moderators: russ, Ralph

Message
Author
User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

is there a way to save a text or csv file from AM ?

#1 Post by jph »

I believe the answer is 'no' as the appropriate lua commands don't seem to be available, but I thought I would ask if anyone has a 'cunning plan' or if it is planned for a later release ?
thanks
Joe
Joe. CISSP, MSc.

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: is there a way to save a text or csv file from AM ?

#2 Post by Keith Baxter »

Joe,

Use Persistence



Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: is there a way to save a text or csv file from AM ?

#3 Post by jph »

Hi Keith, I am persistent :lol:

Can you explain a bit more please ?.

I have a setup program in development that reads inputs from a 128 input card.
It doesn't matter what connects to what pin as the pin number will be highlighted when the input is activated, for instance, if I press button X or activate switch Y or encoder Z then the graphic shows which inputs they are connected to.
I want to save that data to a file for use during setup or for importing into excel.

Joe
Joe. CISSP, MSc.

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: is there a way to save a text or csv file from AM ?

#4 Post by Keith Baxter »

jph wrote: Wed Sep 21, 2022 7:12 am Hi Keith, I am persistent :lol:

Can you explain a bit more please ?.

I have a setup program in development that reads inputs from a 128 input card.
It doesn't matter what connects to what pin as the pin number will be highlighted when the input is activated, for instance, if I press button X or activate switch Y or encoder Z then the graphic shows which inputs they are connected to.
I want to save that data to a file for use during setup or for importing into excel.

Joe
Joe,

https://siminnovations.com/wiki/index.p ... ersist_add

You can check the file. it is stored here. But the file is only written after the instrument is shut down.

C:\Users\Keith\Air manager BETA\persistence\instrument_plugin

For instance. I store flightplans

Code: Select all

[{
		"key":	"FAOR-FACT",
		"value":	["FAOR", "GAV", "EKBEX", "APDUR", "KYV", "EGRUP", "VWV", "SLV", "CSV", "CTV", "FACT"]
	}]
So store your data in a table first then use the persist_put() function to update your persistence file.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: is there a way to save a text or csv file from AM ?

#5 Post by jph »

Hey thanks Keith ! - I never noticed that one at all. I was trying to use the lua file functions - doh ;)

That is extremely useful !.

I am making a list of the inputs - such as - HYD Panel 1 FWD ON, HYD Panel 1 AFT ON, HYD Panel 2 FWD ON, HYD Panel 2 AFT ON, etc etc etc

the user then just wires everything up to anything they want on the input board(s), the program says, ok - now select - HYD Panel 1 FWD ON
the graphic will highlight the input that was activated and the user can chose to save that as that function. User properties are not suitable or what I need for this.

An example of the type of graphic without any text and data added (a VERY early example)
mux select input display 1.jpg
This will be run as a completely separate 'instrument' and just used for setup. The user can connect anything to anything this way.
That's the plan.
A similar thing with output board(s) will also be the case (where outputs are of a specific type - such as 7 segment, led, light, etc etc) so again, no bothers about what they wire to what. All sorted in setup.

I 'might' use visual basic, but I haven't used it since V6 :o
Joe
Joe. CISSP, MSc.

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: is there a way to save a text or csv file from AM ?

#6 Post by Keith Baxter »

Joe,

That should be easy to do. As long as you understand lua tables and .json file structure.
This test example takes data from a .json file and add it to a persistence file.

Run this instrument and then check the persistence file .json

You can manipulate the data as you want and use it then save it.

I just did this short example that has a complex .json structure to demonstrate the power of persistence. This is obviously for the advanced user as a understanding.

The only issue I have is that AM hangs while the persistence file is written when the file is LARGE.
Like when you load one of the NAV DATA files and then strip out the data you want. I use it as a tool to compare the AM nav data to the Navigraph nav data. :D


.
Airspace Boundry json file stripper CLONE.siff
(134.37 KiB) Downloaded 26 times
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: is there a way to save a text or csv file from AM ?

#7 Post by jph »

Hi Keith, thanks for that.

I have no issues with LUA tables (glorified arrays on steroids ;) ) , but haven't looked at .Json files. I will peruse your example, appreciated.

The data only needs to go into AM once so if the setup program is in AM or in another program, VB maybe, or in AM and passed to an SD Card on the Pico :D , it doesnt really matter as the correct final file formatting for AM can be done in Excel if needed. I already use excel to format the Zibo data directly from the dataref and command list for direct import.
I am sure it can all be done in AM but as said, its not a big deal if it is handled outside of AM and the mapping passed to AM later even by cut and paste from a saved excel sheet.


Out of interest I was just thinking about the 7 segment output drivers which will be - almost certainly - 7219 units. I am thinking perhaps an output board with up to 64 digits per board. (The chip modules will be socketed so only as many as needed need to be plugged in - minimum 4 modules on a pre built cheap block = 32 digits). I am using messageport but the same hardware principle could be used with the AM functions.
7 segment drivers -
The software for reading the input can work in reverse to the input selection (caveat - if using messageport), you could, in theory, wire any digit to any digit output in any order, normally it would be logical, but it doesn't have to be, then you can select - digit x, where x = 0 to 63, and wherever it illuminates is set as its position. So no worries about the order and placement of the digits as the controllers would all be on the driver board and the led 7 seg blocks would be at the instrument end. Only the number of digits used per display would be utilised so one 7219 would drive 8 digits meaning where there are, say, 4 x 6 digits then only 3 x 7219 units are used.

Moving the controllers (the 7219 for example) completely away from the actual 7 segment block is a far better way.

Just thinking out loud :)

You use whatever size of 7 segment display you want and any number of digits or combination of digit blocks.
Wire it all up as you want it and it is the set up that does what you want later so you don't have to care about what goes where - providing the segments and digit pins are correctly wired of course.. Makes wiring really simple.

For drivers for 7 segments I am using these -
https://www.aliexpress.com/item/1005003 ... 1802vbROeT
they are basically 4 x 7219 units on a single pcb, but can be cut as required and are in fact, designed that way - four identical units in a row - although I wont be cutting them as I don't need to. The fact they are fitted with socketed 64 led matrix units doesn't matter as it is simply the pins we want access to so they get unplugged and thrown away or saved for something else. Then unsolder the 8 x 8 pin sockets and replace them with 8 pin headers pointing downwards, these then plug into a small main board (a 15 x 10 cm proto board for example) with sockets soldered on so the 4 unit block plugs directly in, along with space for another on the same main board. The digit and segment pins are then simply wired to headers of your choice on that support board - IDC in my case. You could then use them wiring compatible with - for example -Hispa panels PCBS and many others. It is also easy to bring the connections out to a couple of 40 pin IDC headers and then take these to a distribution board wired for your own individual segment modules. Nice and modular.

here's a pic of a unit with a matrix unplugged, there are 4 duplicates of these on one module for 5 euros !. just unsolder these sockets and headers and remove and replace with downward pointing pin headers - and add the 10uF cap of course. You only need 3 caps per module, even 2 are enough. I tested them up to 10 MHz hardware SPI and they are great. (that is the max theoretical limit of the 7219) ;)
Max7219-Dot-Matrix-Module-.jpg
Along with your excellent examples, Gilles @SimPassion posted a rather lovely piece of code the other day where functions were embedded in a lua table and I thought it really showed the power of the lua tables. It was from that that the direct import of the command and dataref list from the Zibo documentation was born. That opened my eyes. When I studied the code I thought - wow ! - LUA can do THAT ? !!!. Amazing.

Keep the ideas coming. Excellent stuff.

Joe
Joe. CISSP, MSc.

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: is there a way to save a text or csv file from AM ?

#8 Post by Keith Baxter »

Wow Joe,
That last post grew as the day got longer.😂

I get the path you are exploring.

For me, I do not understand why AM has to use arduino library and load them taking up memory.

Simply loading a .json pointing to a chip make and configuration could save memory and provide ease of adding many chip types.

But I am not clever enough to know the ins and outs. Just my thoughts.

Hmmm :?: :?: :?:
Watch this space...

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: is there a way to save a text or csv file from AM ?

#9 Post by Keith Baxter »

Hi

I am going OT here but it is related to saving persistence and file manipulation.

Lets take a simple 7 segment . We could use this bin and then just map each chip output ...
img1.png
img1.png (5.39 KiB) Viewed 405 times
Am I missing something if a .json could look something similar....

Code: Select all

byte segCode[11][8] = {
//  a  b  c  d  e  f  g  .
  { 0, 0, 0, 0, 0, 0, 0, 0},  // nil
  { 1, 1, 1, 1, 1, 1, 0, 0},  // 0
  { 0, 1, 1, 0, 0, 0, 0, 0},  // 1
  { 1, 1, 0, 1, 1, 0, 1, 0},  // 2
  { 1, 1, 1, 1, 0, 0, 1, 0},  // 3
  { 0, 1, 1, 0, 0, 1, 1, 0},  // 4
  { 1, 0, 1, 1, 0, 1, 1, 0},  // 5
  { 1, 0, 1, 1, 1, 1, 1, 0},  // 6
  { 1, 1, 1, 0, 0, 0, 0, 0},  // 7
  { 1, 1, 1, 1, 1, 1, 1, 0},  // 8
  { 1, 1, 1, 1, 0, 1, 1, 0},  // 9
  { 0, 0, 0, 0, 0, 0, 0, 1}   // .
};
As I understand. The 0's are the led components within the display that are not laminated. The 1's are components laminated.

This simply allows for many custom characters. Even more than 7 seg display options.


I must confess I am out of my depth with knowledge when it comes to this subject. But hay I am only a hacker with some dangerous knowledge and lots of wanting for new things. :) You can blame @Corjan for that. He teaches in a silent way. The less he says the more you research, question and learn. Nothing comes on a silver spoon and I am better for that and have learned a great deal of knowledge from that approach. :) An appreciated mentor that has taught me directly and indirectly over the years. ;) It is only correct that I try and pass on those learning's to others and spawn other ideas.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: is there a way to save a text or csv file from AM ?

#10 Post by jph »

Hi Keith,
the 1s and 0s are simply states, on and off of the led segments.
The 7219 operates in two modes, the first is BCD (standard binary code decimal) - called 'DECODE MODE' where you set four bits of an appropriate register to the number you require - 0 - 9 - in binary - and it will 'decode' and send the correct segment info. As the 4 bit binary allows 16 combinations it also supports H,E,L,P,- and blank from the decode mode.

OR, you operate it in direct addressing mode where it has absolutely no concept of 7 segment display at all. This is called 'NO DECODE MODE' or simply the 'decode mode' bit is not set in the control register. All the info you send it you take from a lookup table similar to as you have above. Have a read through the data sheet for the device, it covers the 2 modes.
Corjan is using the NO DECODE MODE to allow for the extra alpha characters that were requested so it is all lookup based already but the table is fixed somewhere at either the AM end or the Arduino code end - when I say 'arduino' I am using it as a generic term for anything that supports AM flashing.
You can send anything you want to the 7219 if you code and the code that you are using - AM and the Arduino side - supported it.

At the moment it supports what is published only. It is easy to write a routine using messageport to give you full control over the 7219 to send anything you want to it and set any segment on any device at any time.

Here is the WHOLE code to control every possible aspect of a MAX7219 (at the micro end) Messageport can be added to this easily so you do ANYTHING from AM - I can do that if you like (when I get time) ?

This is for a single device, but it can be modded to drive 8 x 7219 units per hardware SPI port on the device.
The pico has TWO - HARDWARE SPI on each chip meaning i can run 16 max 7219 units (128 digits) without breaking into a sweat as the on board hardware SPI units do the work leaving the dual cores of the processor to do other things.

I can sort you something out if you want to play ?
You can follow the datasheet while looking at the code below that I use to drive a 7219. You can do ANYTHING to a 7219 with this code.
You just call either maxTransferData or maxTransferCmd.
I can make it so you have full control of the 7219 command and data registers from Air Manager via messageport if you like ? - then you can do anything you like with it ?

Code: Select all

/*
******************************************************************************************************
*                                                                                                    *
*                             Joe Hanley 2022  (JPH Air Manager forums)                              *
*                                                                                                    *
****************************************************************************************************** 
*/

// includes 
#include <SPI.h> 
                                                                                 		 
// defines
#define MAX7219_CS 10 // chip select

// MAX7219 SPI LED Driver command register addressing. // refer to max7129 datasheet for information on using these
// register addresses   0xX1 - 0xX8 are digits 0 to 7 and 0xX0 is no-op where X is 'don't care'
#define MAX7219_TEST        0x0f           
#define MAX7219_BRIGHTNESS  0x0a   
#define MAX7219_SCAN_LIMIT  0x0b       
#define MAX7219_DECODE_MODE 0x09   
#define MAX7219_SHUTDOWN    0x0C   

// constants
 
// global variables

//****************************************************************************************************

void setup() {                                // setup: run once
  
  //Serial3.begin(115200);
  //Serial3.println("Debug MAX7219");
  
  pinMode(MAX7219_CS, OUTPUT);
  SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));  // maximum 10 MHz max speed of MAX7219 SPI, MSBFIRST and MODE0.
  /*  SPISettings
   *  the UNO is NOT going to reach 10MHz but other boards will.
   *  MODE0 is BY FAR the most common mode used in SPI, it is amost universal.
   *  MSBFIRST is used with the MAX7219
   */

  SPI.begin();                   // Start SPI // Initializes the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low, and SS high.

  // set up and ititialise the max7219
  maxTransferCmd(MAX7219_TEST,        0x01 );    // run test - all LED segments lit. 
  delay(1000);                                   // allow time for leds to be illuminated for test.
  maxTransferCmd(MAX7219_TEST,        0x00 );    // finish led all lit test.
  maxTransferCmd(MAX7219_DECODE_MODE, 0x00 );    // disable BCD mode.
  maxTransferCmd(MAX7219_BRIGHTNESS,  0x0f );    // set intensity. 0 - 15  // 0x00 to 0x0F 
  maxTransferCmd(MAX7219_SCAN_LIMIT,  0x0F );    // Scan all digits. // DO NOT CHANGE without referring to datasheet. This does NOT refer to number of 7219 devices !!
  maxTransferCmd(MAX7219_SHUTDOWN,    0x01 );    // Turn on chip. NOT shutdown.

}  // run once setup end

//****************************************************************************************************

void loop() {                  // main program loop 

       
     
}                              // main program loop end

/*
              ****************************************************************************************************** 
              *                                           Subroutines                                              *
              ******************************************************************************************************
*/
/* transfer a CMD code and its value to the MAX7219 */
void maxTransferCmd(uint8_t maxAddress, uint8_t maxData) {    // we could use same call as maxTransferData but this makes it easier to read
  maxWrite16bits(maxAddress,maxData);
}
/* ************************************************************************************************ */

/* transfer data address and row value to MAX7219 // here it is 'row' with value 1 to 8 */
void maxTransferData(uint8_t maxAddress, uint8_t maxData) {   // we could use same call as maxTransferCmd but this makes it easier to read
  maxWrite16bits(maxAddress,maxData);
}
/* ************************************************************************************************ */

void maxWrite16bits(uint8_t maxAddress,uint8_t maxData) {    // sends the Hardware SPI data to the MAX7219
                                                             // same routine for CMD or DATA, just different call for clarity
  digitalWrite(MAX7219_CS, LOW);    // start transfer        
  SPI.transfer(maxAddress);         // Send the address byte     
  SPI.transfer(maxData);            // Send the data byte  
  digitalWrite(MAX7219_CS, HIGH);   // finish transfer       
   
}                                                            // end of maxWrite16bits

Joe. CISSP, MSc.

Post Reply