Giter Site home page Giter Site logo

Example code does not work: max7219.lua:70: bad argument #1 to 'ipairs' (table or rotable expected, got nil) about nodemcu-max7219 HOT 5 CLOSED

marcelstoer avatar marcelstoer commented on June 11, 2024
Example code does not work: max7219.lua:70: bad argument #1 to 'ipairs' (table or rotable expected, got nil)

from nodemcu-max7219.

Comments (5)

marcelstoer avatar marcelstoer commented on June 11, 2024

Which example? The one from https://github.com/marcelstoer/nodemcu-max7219/blob/master/README.md?
How does summy2.lua:3 look?

from nodemcu-max7219.

tricoos avatar tricoos commented on June 11, 2024

The official example code - summy2.lua (which should be called dummy2.lua btw) just contains the first lines of the example:

max7219 = require("max7219")
max7219.setup({debug = true, numberOfModules = 4, slaveSelectPin = 8})
max7219.write({
    { 0x20, 0x74, 0x54, 0x54, 0x3C, 0x78, 0x40, 0x00 },
    { 0x41, 0x7F, 0x3F, 0x48, 0x48, 0x78, 0x30, 0x00 },
    { 0x38, 0x7C, 0x44, 0x44, 0x6C, 0x28, 0x00, 0x00 },
    { 0x30, 0x78, 0x48, 0x49, 0x3F, 0x7F, 0x40, 0x00 }
  }, { rotate = "left" })

This in conjunction with the latest max7219.lua from the repo leads to this error.

from nodemcu-max7219.

marcelstoer avatar marcelstoer commented on June 11, 2024

I know that it worked when I last tested. Might be that the changes I pulled in from someone else's fork (45e4460) broke something.

from nodemcu-max7219.

tricoos avatar tricoos commented on June 11, 2024

I could fix it by changing the code to

local c = {}
  for i,char in pairs(chars) do 
  --for i = 1, #chars do
  --  local char = chars[i]
    if transformation.rotate ~= nil then
--      char = rotate(char, transformation.rotate == "left")
    end

However, I still couldn't get it to work with CS connected to D8 (the default in the example) - both displays (I have connected two right now) had all LEDs turned on and nothing could change that. It also locked up the USB connection to the PC (ESPlorer). After connecting CS to D2 and changing it in the code (slaveSelectPin = 2) it works now perfectly.

from nodemcu-max7219.

marcelstoer avatar marcelstoer commented on June 11, 2024

I can't reproduce any of this, works just fine over here.

Furthermore, I find you initial stacktrace a bit odd:

max7219.lua:70: in function '?'
max7219.lua:177: in function 'write'

Line 70 accesses the char passed to rotate() as a parameter. It seems to be nil so it was missing upon invocation.
Your stack trace says rotate() was called from line 177 but that can't be. The actual invocation is further down on line 180. Be that as it may it looks as if max7219. write () wasn't passed any characters.

from nodemcu-max7219.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.