diff --git a/SConstruct b/SConstruct index a37dad0b..cc7517a4 100644 --- a/SConstruct +++ b/SConstruct @@ -103,7 +103,7 @@ file_list = { 'SAM7-EX256' : [ 'bisect', 'hangman' , 'led', 'piano', 'hello', 'i 'EK-LM3S8962' : [ 'bisect', 'hangman', 'lhttpd', 'pong', 'led', 'piano', 'pwmled', 'tvbgone', 'hello', 'info', 'morse', 'adcscope','adcpoll' ], 'EK-LM3S6965' : [ 'bisect', 'hangman', 'lhttpd', 'pong', 'led', 'piano', 'pwmled', 'tvbgone', 'hello', 'info', 'morse', 'adcscope','adcpoll' ], 'STR9-COMSTICK' : [ 'bisect', 'hangman', 'led', 'hello', 'info' ], - 'PC' : [ 'bisect', 'hello', 'info', 'life' ], + 'PC' : [ 'bisect', 'hello', 'info', 'life', 'hangman' ], 'LPC-H2888' : [ 'bisect', 'hangman', 'led', 'hello', 'info' ], 'MOD711' : [ 'bisect', 'hangman', 'led', 'hello', 'info', 'dualpwm' ], 'STM3210E-EVAL' : [ 'bisect', 'hello', 'info' ], diff --git a/doc/en/examples.html b/doc/en/examples.html index b11b9b3d..0b797237 100644 --- a/doc/en/examples.html +++ b/doc/en/examples.html @@ -1,127 +1,128 @@ -Product +eLua examples -

Lua Code Examples

eLua distros come bundled with nice and fun -(yes! we have games too! :) Lua programs examples in the File System. -They are also included in the eLua -source code distribution, under the /romfs subdirectory.
Lua example programs for eLua are also presented and commented here.
As previously explained, you can run them directly from eLua's file +

Lua Code Examples

+

eLua distros come bundled with nice and fun +(yes! we have games too! :) Lua programs examples in the File System. They are also included in the eLua +source code distribution, under the /romfs subdirectory. As previously explained, you can run them directly from eLua's file system or you can use the eLua shell and send them via XMODEM, as -described here.

+described here.

-

hello.lua: the ubiquitous "Hello, World!"

- -

Runs on: 
All Targets

- -Description:
To call this a "program" is a gross overstatement, but it's a +

hello.lua: the ubiquitous "Hello, World!"

+

Runs on: all targets

+

Description: to call this a "program" is a gross overstatement, but it's a tradition, so we respect it :) It just prints "Hello, World!" on the terminal and -returns to the shell. Download it only if you feel too lazy to fire up -the lua interpreter inside eLua and write it yourself :)

Commented Source Code:

print("Hello World")

+returns to the shell. Run it from the file system only if you feel too lazy to fire up +the lua interpreter inside eLua and write it yourself :)

-


info.lua: getting the platform data

- -

Runs on: 
All targets except i386

Description:
-This isn't really more advanced than "Hello, World!", but it does show -an eLua specific module: the platform data module (pd). You can read -more about the platform modules in the eLua source distribution -(docs/platform_modules.txt). The program will display the platform +

info.lua: getting the platform data

+

Runs on: all targets

+

Description: this isn't really more advanced than "Hello, World!", but it does show +an eLua specific module: the platform data module (pd). You can read +more about the platform modules ##here. The program will display the platform name, the CPU name, the board name and the CPU clock and then will exit -to the shell.

Commented Source Code:

-- Uses module pd to access platform data and print it on the Terminal
print( "I'm running on platform " .. pd.platform() )  
print( "The CPU is a " .. pd.cpu() )
print( "The board name is " .. pd.board() )

+to the shell.

+

led.lua: the old LED blinker, the new eLua way

-

led.lua: the old LED blinker, the new eLua way

- -

Runs on:
All targets except i386

Description:
-Now we get to do something "more embedded": blink a LED. The code ilustrates a few interesting eLua features:

- -

+

Watch it blink, then press any key to return to the eLua shell.

-

Watch it blink, then press any key to return to the eLua shell.

Commented Source Code:

- -

hangman.lua: taking advantage of your terminal

- -

Runs on: 
All Targets except i386

- -

Description:
By far the geekiest example from the eLua distribution (or would it be morse.lua? :), it makes use of -the term module (docs/terminal_support.txt) to let the user play a -BSD-like "hangman" directly in his terminal emulator. Run the example +

hangman.lua: taking advantage of your terminal

+

Runs on: all targets

+

Description: the geekiest example from the eLua distribution (or would it be morse.lua? :), it makes use of +the ##term module to let the user play a BSD-like "hangman" directly in his terminal emulator. Run the example and enjoy. Currently it has a very small list of words, as this was written mainly as a proof of eLua's capabilities, but it's very easy to -add new words/replace the existing ones. A screenshot can be seen here.

+add new words/replace the existing ones. A screenshot can be seen ##here.

-

pwmled.lua: LED blinker, advanced class

Runs on: 
EK-LM3S8962, EK-LM3S6965

- -

Description:
-This uses the PWM module to fade the on-board LED in and out, in an +

pwmled.lua: LED blinker, advanced class

+

Runs on: EK-LM3S8962, EK-LM3S6965

+

Description: this uses the PWM module to fade the on-board LED in and out, in an infinite loop. Not much to say here, the code is very simple, yet the results are quite spectacular. Press any key to end the sample and -return to the shell.

+return to the shell.

-

tvbgone.lua: yes, eLua can do real time!

+

dualpwm.lua: because a single LED is just not enough

+

Runs on: MOD711

+

Description: My MOD711 board needed a +"motherboard" for a few components (mainly the RS232-TTL level converter and a reset button) so I also added two LEDs to it, connected +to two different PWM channels. With this program, the two LEDs fade at the same type, but in different directions.

-

Runs on: 
EK-LM3S8962, EK-LM3S6965

+

pong.lua: eLua meets a classic

+

Runs on: EK-LM3S8962, EK-LM3S6965

+

Description: a very simple, incomplete implementation of the famous pong +game. It uses the display and keys on the EK-LM3S8962 or EK-LM3S6965 boards. It uses a platform dependent module (disp) and also shows how +require can be used from eLua.You can set different game speeds. Enjoy! :)

-

Description:
This is more complex, but also very important for eLua, because it +

tvbgone.lua: yes, eLua can do real time!

+

Runs on: EK-LM3S8962, EK-LM3S6965

+

Description: this is more complex, but also very important for eLua, because it proves that real time applications (with relatively strict timing -requirements) can run from eLua directly. It's the famous TV-B-Gone -project adapted from LadyAda's kit. +requirements) can run from eLua directly. It's the famous TV-B-Gone +project adapted from LadyAda's kit. If you're not familiar with TV-B-Gone, it knows how to do one thing very well: power off your TV :) Basically it contains a lot of remote control codes (for a lot of TVs) that are continously sent via an IR -LED. This code uses the PWM module (new in eLua 0.4) and it also does +LED. This code uses the PWM module (new in eLua 0.4) and it also does file I/O from Lua, since the remote control codes are kept in a separate file (which is also part of the ROM file system). To read the binary file, the "pack" module (also new in 0.4) is used. To ensure that we don't get any unexpected delays, the Lua garbage collector is turned off. Take a look at this sample, it's both a very good proof of -the capabilities of eLua and a good learning resource. To use it on any -of the Cortex boards (EK-LM3S8962 or EK-LM3S6965) connect an IR LED +the capabilities of eLua and a good learning resource.
+To use it on EK-LM3S8962 or EK-LM3S6965 connect an IR LED with a resistor between the "PWM2" and "GND" pins of the extension connector. Get close to your TV and press the "select" button on your board to start sending the IR codes. The on-board LED stays lit while the codes are transmitted and shuts off afterwards. Press the "down" -button on your board to exit the application and return to the shell.

+button on your board to exit the application and return to the shell.

-

piano.lua: because PWM is great

Runs on: 
EK-LM3S8962, EK-LM3S6965, SAM7-EX256

- -

Description:
-Yet another use for the PWM module, this sample can be used to "play" +

piano.lua: because PWM is great

+

Runs on: EK-LM3S8962, EK-LM3S6965, SAM7-EX256

+

Description: yet another use for the PWM module, this sample can be used to "play" notes via the on-board speaker using the PC keyboard. The on-screen keyboard shows what keys you must press for different notes, and you -can set your octave and inter-note delay. Press ESC to end your eLua -musical session :) A screenshot can be seen here.

+can set your octave and inter-note delay. Press ESC to end your eLua +musical session :) A screenshot can be seen here.

-

bisect.lua: floating point at its best

- -

Runs on: 
All Targets

- -

Description:
This is taken directly from the official Lua distribution, and it's -here to show that eLua can do floating point just like on a desktop +

bisect.lua: floating point at its best

+

Runs on: all targets

+

Description: this is taken directly from the official Lua distribution, and it's +here to show that eLua can do floating point just like on a desktop machine, albeit slower. Run it on your target, then run it again, but -this time on the PC, and compare the results. Yes, they are identical.

+this time on the PC, and compare the results. Yes, they are identical.

-

morse.lua: because PWM is great, part II

+

life.lua: the game of life

+

Runs on: i386

+

Description: another example taken directly from the Lua distribution, this time +the well known game of life. +Start it and enjoy. Only included on i386 by default because it's faster on i386, but it can run on other +platform too (although it requires quite a bit of memory, which is not a problem for boards with external +memory).

-

Runs on: 
EK-LM3S8962, EK-LM3S6965, SAM7-EX256

- -

Description:
This uses the same PWM module for Morse code generation. Just enter a +

morse.lua: because PWM is great, part II

+

Runs on: EK-LM3S8962, EK-LM3S6965, SAM7-EX256

+

Description: this uses the same PWM module for Morse code generation. Just enter a text, and listen to it getting Morsed on your board's speaker and on a blinking Led. The letters and Morse codes are also shown on the terminal. Use '+' and '-'' to change the frequency, up and down arrows to change the speed, -'s' to mute/unmute, and ESC to exit.

+'s' to mute/unmute, and ESC to exit.

-

lhttpd.lua: only with (e)Lua ...

- -

Runs on: 
EK-LM3S8962, EK-LM3S6965 - -

Description:
This is one of those things that can show the real potential of a -language (and hopefully the real potential of eLua in this case). As +

lhttpd.lua: only with (e)Lua ...

+

Runs on: EK-LM3S8962, EK-LM3S6965

+

Description: this is one of those things that can show the real potential of a +language (and hopefully the real potential of eLua in this case). As you have probably guessed by now, it's a web server written in Lua. -Except that it is much more than this: it's a scripting web server! That's +Except that it is much more than this: it's a scripting web server! That's right, you can embed parts of Lua code into your pages, and the server will parse them and replace the Lua code with its output. To output something from Lua code embedded in a web page, simply use "print" in @@ -139,6 +140,18 @@ and replace the Lua code with its output

  • if a file with it and sends its output (via "print" statements)
  • This is still work in progress, but it already works quite well. -Take a look at romfs/index.pht and romfs/test.lua from the source +Take a look at romfs/index.pht and romfs/test.lua from the source distribution for an example of how to include Lua code in your HTML -files.

    \ No newline at end of file +files.

    + +

    adcscope.lua: ADCs and eLua, part I

    +

    Runs on: ##TODO

    +

    Description: ##TODO +

    + + +

    adcpoll.lua: ADCs and eLua, part II

    +

    Runs on: ##TODO

    +

    Description: ##TODO +

    + diff --git a/doc/en/versionhistory.html b/doc/en/versionhistory.html index ac240fc0..ebe84e97 100644 --- a/doc/en/versionhistory.html +++ b/doc/en/versionhistory.html @@ -1,9 +1,90 @@ -Product +eLua version history -

    eLua Version's History

    - -

    \ No newline at end of file + +

    eLua version history

    +

    The table below presents the history of all official eLua releases (in reversed order, newest to oldest).

    + +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    VersionRelease dateDescription
    0.501.11.2008
      +
    • Added support for STR7 CPUs from ST
    • +
    • Added TCP/IP support using the uIP stack
    • +
    • Added support for console and shell over TCP/IP besides the previous serial link
    • +
    • Added the "net" module (eLua's interface to TCP/IP functions)
    • +
    • Added the "cpu" module (eLua's interface to the target CPU)
    • +
    • New samples: morse.lua (Morse code encoder), lhttpd.lua (Lua scripting HTTP server)
    • +
    • Added support for cross-compiling Lua code (compile on PC, run on target)
    • +
    • XMODEM can now receive Lua bytecode in addition to Lua source code
    • +
    • The XMODEM buffer is now dynamic (grows as needed) instead of fixed size
    • +
    • Project documentation updated
    • +
    0.4.110.09.2008
      +
    • changed from Lua version 5.1.3 to Lua version 5.1.4
    • +
    • Changed the file system structure; now you can build both Lua versions (floating point and int only) from the same directory
    • +
    • Made the math library configurable using the existent 'platform libraries' mechanism
    • +
    • The "os" and "package" modules are no longer loaded by Lua, since they can't be used anyway. Because of this, the code size of eLua was reduced.
    • +
    • Project documentation updated
    • +
    0.402.09.2008
      +
    • Added support for LPC2888 (preliminary)
    • +
    • Added PWM module
    • +
    • New samples: TV-B-Gone (power off your TV), piano (play piano from your PC keyboard), pwmled (fade led on/off), all based on the new PWM module
    • +
    • Added support for multiple memory spaces (this can be used to take advantage of both the internal CPU RAM and external RAM chips on boards that have external RAM)
    • +
    • Autorun: if "autorun.lua" is found in the filesystem, it is executed before starting the shell
    • +
    • Added "pack" (binary data packing/unpacking) and "bit" (binary operations) modules
    • +
    • Build system updated, easier to use, now it knows how to handle "boards" as well as CPUs
    • +
    • Modified the existing platform modules to take less RAM and to report an error when an unavailable resource is requested
    • +
    • Project documentation updated
    • +
    0.309.08.2008
      +
    • Now you can play hangman directly from eLua :), thanks to the new "term" module that handles ANSI escape sequences
    • +
    • Added support for ST STR912FAW44
    • +
    • Added support for Cortex LM3S6965
    • +
    • More intuitive and flexible build system (new syntax, component selection at build time)
    • +
    • eLua examples are now part of the repository
    • +
    • Project documentation updated
    • +
    0.227.08.2008
      +
    • Added support for Cortex LM3S8962
    • +
    • New platform modules (UART, SPI, Timer, platform data)
    • +
    • First release of the shell
    • +
    • Lua source files can now be sent to target with XMODEM
    • +
    • You can download binary file images from the "files" section, so you don't need to compile eLua yourself
    • +
    0.111.08.2008
    • Initial release, had support for i386 and AT91SAM7X platform
    + diff --git a/doc/style.css b/doc/style.css index 111763f5..7c3d0e0f 100644 --- a/doc/style.css +++ b/doc/style.css @@ -26,7 +26,7 @@ table { margin-left: 1em; } pre { - border: 1px solid #62a0ff; + border: 1px dashed #62a0ff; padding: 4px; background-color: #cee7ff; font-family: 'Monotype.com',"Courier New",Courier,monospace; diff --git a/doc/wb/wb_usr.lua b/doc/wb/wb_usr.lua index 10666f9c..b7405268 100755 --- a/doc/wb/wb_usr.lua +++ b/doc/wb/wb_usr.lua @@ -85,6 +85,68 @@ wb_usr.tree = }, }, }, + + { + name = { en = "Downloads", pt = "Downloads" }, + link = "dl_binaries.html", + folder = + { + { + name = { en = "Binaries", pt = "Binaries" }, + link = "dl_binaries.html", +--[[ + folder = + { + { + name = { en = "Atmel", pt = "Atmel" }, + link = "lm_bin.html", + }, + { + name = { en = "Luminary Micro", pt = "Luminary Micro" }, + link = "lm_bin.html", + }, + { + name = { en = "PC i386", pt = "PC i386" }, + link = "lm_bin.html", + }, + { + name = { en = "Phillips", pt = "Phillips" }, + link = "lm_bin.html", + }, + { + name = { en = "ST Micro", pt = "ST Micro" }, + link = "lm_bin.html", + }, + }, +--]] + }, + { + name = { en = "Source Code", pt = "Fontes" }, + link = "dl_sources.html", + folder = + { + { + name = { en = "Official Releases", pt = "Versões Oficiais[B" }, + link = "dl_sources.html" + }, + { + name = { en = "SVN Public", pt = "SVN Público" }, + link = "dl_sources.html#svnpublic" + }, + { + name = { en = "Developers", pt = "Desenvolvedores" }, + link = "dl_sources.html#svndev" + }, + }, + }, + { + name = { en = "Old Versions", pt = "Versões Anteriores" }, + link = "dl_old.html" + }, + + }, + }, + { name = {en = "Community", pt = "Comunidade" }, link = "comunity.html", @@ -250,39 +312,6 @@ wb_usr.tree = { name = { en = "Examples", pt = "Exemplos" }, link = "examples.html", - folder = - { - { name = { en = "hello.lua", pt = "hello.lua" }, - link = "examples.html#hello", - }, - { name = { en = "info.lua", pt = "info.lua" }, - link = "examples.html#info", - }, - { name = { en = "led.lua", pt = "led.lua" }, - link = "examples.html#led", - }, - { name = { en = "hangman.lua", pt = "hangman.lua" }, - link = "examples.html#hangman", - }, - { name = { en = "pwmled.lua", pt = "pwmled.lua" }, - link = "examples.html#pwmled", - }, - { name = { en = "tvbgone.lua", pt = "tvbgone.lua" }, - link = "examples.html#tvbgone", - }, - { name = { en = "piano.lua", pt = "piano.lua" }, - link = "examples.html#piano", - }, - { name = { en = "bisect.lua", pt = "bisect.lua" }, - link = "examples.html#bisect", - }, - { name = { en = "morse.lua", pt = "morse.lua" }, - link = "examples.html#morse", - }, - { name = { en = "lhttpd.lua", pt = "lhttpd.lua" }, - link = "examples.html#lhttpd", - }, - }, }, { name = { en = "Tutorials", pt = "Tutoriais" }, @@ -318,18 +347,6 @@ wb_usr.tree = { name = {en = "Version History", pt = "Histórico de Versões" }, link = "versionhistory.html", - folder = - { - { name = { en = "v 0.4", pt = "v 0.4" }, - link = "versionhistory.html#04", - }, - { name = { en = "v 0.5", pt = "v 0.5" }, - link = "versionhistory.html#05", - }, - { name = { en = "v 0.6", pt = "v 0.6" }, - link = "versionhistory.html#06", - }, - }, }, }, }, @@ -760,69 +777,5 @@ wb_usr.tree = }, }, }, - { - name = { en = "", pt = "" }, -- Horizontal Separator - link = "" - }, - { - name = { en = "Downloads", pt = "Downloads" }, - link = "dl_binaries.html", - folder = - { - { - name = { en = "Binaries", pt = "Binaries" }, - link = "dl_binaries.html", ---[[ - folder = - { - { - name = { en = "Atmel", pt = "Atmel" }, - link = "lm_bin.html", - }, - { - name = { en = "Luminary Micro", pt = "Luminary Micro" }, - link = "lm_bin.html", - }, - { - name = { en = "PC i386", pt = "PC i386" }, - link = "lm_bin.html", - }, - { - name = { en = "Phillips", pt = "Phillips" }, - link = "lm_bin.html", - }, - { - name = { en = "ST Micro", pt = "ST Micro" }, - link = "lm_bin.html", - }, - }, ---]] - }, - { - name = { en = "Source Code", pt = "Fontes" }, - link = "dl_sources.html", - folder = - { - { - name = { en = "Official Releases", pt = "Versões Oficiais[B" }, - link = "dl_sources.html" - }, - { - name = { en = "SVN Public", pt = "SVN Público" }, - link = "dl_sources.html#svnpublic" - }, - { - name = { en = "Developers", pt = "Desenvolvedores" }, - link = "dl_sources.html#svndev" - }, - }, - }, - { - name = { en = "Old Versions", pt = "Versões Anteriores" }, - link = "dl_old.html" - }, - - }, - }, }, } diff --git a/doc/wb_search_en.txt b/doc/wb_search_en.txt index e6eb83ae..e68420d9 100644 --- a/doc/wb_search_en.txt +++ b/doc/wb_search_en.txt @@ -18,16 +18,16 @@ en/tutorials.html en/arch_coding.html en/tut_openocd.html en/refman.html -en/arch_newport.html -en/arch_romfs.html en/net_ref.html -en/tchainbuild.html +en/arch_romfs.html +en/arch_newport.html +en/tc_arm.html en/arch_ltr.html en/installing_avr32.html en/installing_str7.html en/installing_at91sam7x.html en/installing.html -en/tc_arm.html +en/tchainbuild.html en/using.html en/versionhistory.html en/toolchains.html diff --git a/doc/wb_search_pt.txt b/doc/wb_search_pt.txt index f0c8cca5..3a9e2999 100644 --- a/doc/wb_search_pt.txt +++ b/doc/wb_search_pt.txt @@ -18,16 +18,16 @@ pt/tutorials.html pt/arch_coding.html pt/tut_openocd.html pt/refman.html -pt/arch_newport.html -pt/arch_romfs.html pt/net_ref.html -pt/tchainbuild.html +pt/arch_romfs.html +pt/arch_newport.html +pt/tc_arm.html pt/arch_ltr.html pt/installing_avr32.html pt/installing_str7.html pt/installing_at91sam7x.html pt/installing.html -pt/tc_arm.html +pt/tchainbuild.html pt/using.html pt/versionhistory.html pt/toolchains.html diff --git a/doc/wb_tree_en.html b/doc/wb_tree_en.html index 03daf42f..35465028 100644 --- a/doc/wb_tree_en.html +++ b/doc/wb_tree_en.html @@ -228,231 +228,213 @@

    Contacts

    License

    -

    Community

    +

    Downloads

    -

    Lists

    -

    Forums

    -

    Credits

    +

    Binaries

    +

    Source Code

    +
    +

    Official Releases

    +

    SVN Public

    +

    Developers

    +
    +

    Old Versions

    -

    News

    -

    Status

    +

    Community

    -

    Platforms Supported

    -

    Roadmap

    +

    Lists

    +

    Forums

    +

    Credits

    -

    -

    Documentation

    +

    News

    +

    Status

    -

    Building

    -
    -

    Toolchains

    -
    -

    Installing

    -
    -

    AT91SAM7X

    -

    LM3S

    -

    AVR32

    -

    LPC288x

    -

    STR7

    -

    STR9

    -

    STM32

    -

    i386

    -
    -

    Using

    -
    -

    Over UART

    -

    Over TCP/IP

    -

    The shell

    -

    Cross-compiling

    -
    -

    FAQ

    -

    Architecture

    -
    -

    Overview

    - -

    Platform interface

    -

    ROM file system

    -

    Adding a new port

    -

    Modules and LTR

    -

    Consoles and terminals

    -

    TCP/IP in eLua

    -

    eLua coding style

    -
    -

    Examples

    -
    -

    hello.lua

    -

    info.lua

    -

    led.lua

    -

    hangman.lua

    -

    pwmled.lua

    -

    tvbgone.lua

    -

    piano.lua

    -

    bisect.lua

    -

    morse.lua

    -

    lhttpd.lua

    -
    -

    Tutorials

    -
    -

    Booting on a PC

    -

    Booting from a Pendrive

    -

    Toolchain Building

    - -

    Using OpenOCD

    -
    -

    Version History

    -
    -

    v 0.4

    -

    v 0.5

    -

    v 0.6

    -
    -
    -

    Reference Manual

    -
    -

    Generic Modules

    -
    -

    bit

    -
    -

    bnot

    -

    band

    -

    bor

    -

    bxor

    -

    lshift

    -

    rshift

    -

    bit

    -

    set

    -

    clear

    -

    isset

    -

    isclear

    -
    -

    cpu

    - -

    gpio

    - -

    net

    - -

    pwm

    - -

    spi

    - -

    sys

    -
    -

    platform

    -

    mcu

    -

    cpu

    -

    board

    -
    -

    term

    - -

    tmr

    - -

    uart

    -
    -

    setup

    -

    send

    -

    recv

    -
    -
    -

    Platform Dependent Modules

    -
    -

    adc

    - -

    disp

    -
    -

    init

    -

    enable

    -

    disable

    -

    on

    -

    off

    -

    clear

    -

    print

    -

    draw

    -
    -
    +

    Platforms Supported

    +

    Roadmap

    -

    Downloads

    -
    -

    Binaries

    -

    Source Code

    -
    -

    Official Releases

    -

    SVN Public

    -

    Developers

    +

    Documentation

    + +

    Reference Manual

    +

    Free Hit Counter

    diff --git a/doc/wb_tree_pt.html b/doc/wb_tree_pt.html index 42891c25..969c35e8 100644 --- a/doc/wb_tree_pt.html +++ b/doc/wb_tree_pt.html @@ -219,240 +219,222 @@

    eLua

    -

    Apresentação

    +

    Apresentação

    -

    Comunidade

    +

    Downloads

    -

    Notícias

    -

    Status

    +

    Comunidade

    -

    -

    Documentação

    +

    Notícias

    +

    Status

    -

    Manual de Referência

    -

    -

    Downloads

    -
    -

    Binaries

    -

    Fontes

    -
    -

    Versões Oficiais[B

    -

    SVN Público

    -

    Desenvolvedores

    +

    Documentação

    + +

    Manual de Referência

    +

    Free Hit Counter

    diff --git a/inc/term.h b/inc/term.h index c13e6141..811aaa8b 100644 --- a/inc/term.h +++ b/inc/term.h @@ -13,7 +13,7 @@ typedef void ( *p_term_out )( u8 ); // Terminal input function typedef int ( *p_term_in )( int ); // Terminal translate input function -typedef int ( *p_term_translate )( u8 ); +typedef int ( *p_term_translate )( int ); // Terminal input mode (parameter of p_term_in and term_getch()) #define TERM_INPUT_DONT_WAIT 0 diff --git a/src/common.c b/src/common.c index 29e6d4c0..b70d0730 100644 --- a/src/common.c +++ b/src/common.c @@ -8,8 +8,104 @@ #include "buf.h" #include #include +#include #include "math.h" #include "elua_adc.h" +#include "term.h" + +// **************************************************************************** +// XMODEM support code + +#ifdef BUILD_XMODEM + +static void xmodem_send( u8 data ) +{ + platform_uart_send( CON_UART_ID, data ); +} + +static int xmodem_recv( u32 timeout ) +{ + return platform_uart_recv( CON_UART_ID, CON_TIMER_ID, timeout ); +} + +#endif // #ifdef BUILD_XMODEM + +// **************************************************************************** +// Terminal support code + +#ifdef BUILD_TERM + +#define TERM_TIMEOUT 100000 + +static void term_out( u8 data ) +{ + platform_uart_send( CON_UART_ID, data ); +} + +static int term_in( int mode ) +{ + if( mode == TERM_INPUT_DONT_WAIT ) + return platform_uart_recv( CON_UART_ID, CON_TIMER_ID, 0 ); + else + return platform_uart_recv( CON_UART_ID, CON_TIMER_ID, PLATFORM_UART_INFINITE_TIMEOUT ); +} + +static int term_translate( int data ) +{ + int c; + + if( isprint( data ) ) + return data; + else if( data == 0x1B ) // escape sequence + { + // If we don't get a second char, we got a simple "ESC", so return KC_ESC + // If we get a second char it must be '[', the next one is relevant for us + if( platform_uart_recv( CON_UART_ID, CON_TIMER_ID, TERM_TIMEOUT ) == -1 ) + return KC_ESC; + if( ( c = platform_uart_recv( CON_UART_ID, CON_TIMER_ID, TERM_TIMEOUT ) ) == -1 ) + return KC_UNKNOWN; + switch( c ) + { + case 0x41: + return KC_UP; + case 0x42: + return KC_DOWN; + case 0x43: + return KC_RIGHT; + case 0x44: + return KC_LEFT; + } + } + else if( data == 0x0D ) + { + // CR/LF sequence, read the second char (LF) if applicable + platform_uart_recv( CON_UART_ID, CON_TIMER_ID, TERM_TIMEOUT ); + return KC_ENTER; + } + else + { + switch( data ) + { + case 0x09: + return KC_TAB; + case 0x16: + return KC_PAGEDOWN; + case 0x15: + return KC_PAGEUP; + case 0x05: + return KC_END; + case 0x01: + return KC_HOME; + case 0x7F: + case 0x08: + return KC_BACKSPACE; + } + } + return KC_UNKNOWN; +} + +#endif // #ifdef BUILD_TERM + // ***************************************************************************** // std functions and platform initialization @@ -30,6 +126,16 @@ void cmn_platform_init() // Set the send/recv functions std_set_send_func( uart_send ); std_set_get_func( uart_recv ); + +#ifdef BUILD_XMODEM + // Initialize XMODEM + xmodem_init( xmodem_send, xmodem_recv ); +#endif + +#ifdef BUILD_TERM + // Initialize terminal + term_init( TERM_LINES, TERM_COLS, term_out, term_in, term_translate ); +#endif } // **************************************************************************** diff --git a/src/main.c b/src/main.c index 940c1b47..8d5befbb 100644 --- a/src/main.c +++ b/src/main.c @@ -17,97 +17,6 @@ extern char etext[]; -// **************************************************************************** -// XMODEM support code - -#ifdef BUILD_XMODEM - -static void xmodem_send( u8 data ) -{ - platform_uart_send( CON_UART_ID, data ); -} - -static int xmodem_recv( u32 timeout ) -{ - return platform_uart_recv( CON_UART_ID, CON_TIMER_ID, timeout ); -} - -#endif // #ifdef BUILD_XMODEM - -// **************************************************************************** -// Terminal support code - -#ifdef BUILD_TERM - -static void term_out( u8 data ) -{ - platform_uart_send( CON_UART_ID, data ); -} - -static int term_in( int mode ) -{ - if( mode == TERM_INPUT_DONT_WAIT ) - return platform_uart_recv( CON_UART_ID, CON_TIMER_ID, 0 ); - else - return platform_uart_recv( CON_UART_ID, CON_TIMER_ID, PLATFORM_UART_INFINITE_TIMEOUT ); -} - -static int term_translate( u8 data ) -{ - int c; - - if( isprint( data ) ) - return data; - else if( data == 0x1B ) // escape sequence - { - // If we don't get a second char, we got a simple "ESC", so return KC_ESC - // If we get a second char it must be '[', the next one is relevant for us - if( platform_uart_recv( CON_UART_ID, CON_TIMER_ID, TERM_TIMEOUT ) == -1 ) - return KC_ESC; - if( ( c = platform_uart_recv( CON_UART_ID, CON_TIMER_ID, TERM_TIMEOUT ) ) == -1 ) - return KC_UNKNOWN; - switch( c ) - { - case 0x41: - return KC_UP; - case 0x42: - return KC_DOWN; - case 0x43: - return KC_RIGHT; - case 0x44: - return KC_LEFT; - } - } - else if( data == 0x0D ) - { - // CR/LF sequence, read the second char (LF) if applicable - platform_uart_recv( CON_UART_ID, CON_TIMER_ID, TERM_TIMEOUT ); - return KC_ENTER; - } - else - { - switch( data ) - { - case 0x09: - return KC_TAB; - case 0x16: - return KC_PAGEDOWN; - case 0x15: - return KC_PAGEUP; - case 0x05: - return KC_END; - case 0x01: - return KC_HOME; - case 0x7F: - case 0x08: - return KC_BACKSPACE; - } - } - return KC_UNKNOWN; -} - -#endif // #ifdef BUILD_TERM - // **************************************************************************** // Program entry point @@ -128,16 +37,6 @@ int main( void ) // Register the ROM filesystem dm_register( romfs_init() ); -#ifdef BUILD_XMODEM - // Initialize XMODEM - xmodem_init( xmodem_send, xmodem_recv ); -#endif - -#ifdef BUILD_TERM - // Initialize terminal - term_init( TERM_LINES, TERM_COLS, term_out, term_in, term_translate ); -#endif - // Autorun: if "autorun.lua" is found in the ROM file system, run it first if( ( fp = fopen( "/rom/autorun.lua", "r" ) ) != NULL ) { diff --git a/src/platform/i386/kb.c b/src/platform/i386/kb.c index a98d44c5..3fb1a1d2 100644 --- a/src/platform/i386/kb.c +++ b/src/platform/i386/kb.c @@ -8,6 +8,7 @@ #include "isr.h" #include "type.h" #include "utils.h" +#include "term.h" #define RSHIFT 0x36 #define LSHIFT 0x2A @@ -21,42 +22,42 @@ static int shift_pressed, ctrl_pressed; * whatever you want using a macro, if you wish! */ const unsigned char kbdus[128] = { - 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */ - '9', '0', '-', '=', '\b', /* Backspace */ - '\t', /* Tab */ - 'q', 'w', 'e', 'r', /* 19 */ - 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', /* Enter key */ - 0, /* 29 - Control */ - 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', /* 39 */ - '\'', '`', 0, /* Left shift */ - '\\', 'z', 'x', 'c', 'v', 'b', 'n', /* 49 */ - 'm', ',', '.', '/', 0, /* Right shift */ + 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */ + '9', '0', '-', '=', '\b', /* Backspace */ + '\t', /* Tab */ + 'q', 'w', 'e', 'r', /* 19 */ + 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', /* Enter key */ + 0, /* 29 - Control */ + 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', /* 39 */ + '\'', '`', 0, /* Left shift */ + '\\', 'z', 'x', 'c', 'v', 'b', 'n', /* 49 */ + 'm', ',', '.', '/', 0, /* Right shift */ '*', - 0, /* Alt */ - ' ', /* Space bar */ - 0, /* Caps lock */ - 0, /* 59 - F1 key ... > */ + 0, /* Alt */ + ' ', /* Space bar */ + 0, /* Caps lock */ + 0, /* 59 - F1 key ... > */ 0, 0, 0, 0, 0, 0, 0, 0, - 0, /* < ... F10 */ - 0, /* 69 - Num lock*/ - 0, /* Scroll Lock */ - 0, /* Home key */ - 0, /* Up Arrow */ - 0, /* Page Up */ + 0, /* < ... F10 */ + 0, /* 69 - Num lock*/ + 0, /* Scroll Lock */ + 0, /* Home key */ + 0, /* Up Arrow */ + 0, /* Page Up */ '-', - 0, /* Left Arrow */ + 0, /* Left Arrow */ 0, - 0, /* Right Arrow */ + 0, /* Right Arrow */ '+', - 0, /* 79 - End key*/ - 0, /* Down Arrow */ - 0, /* Page Down */ - 0, /* Insert Key */ - 0, /* Delete Key */ + 0, /* 79 - End key*/ + 0, /* Down Arrow */ + 0, /* Page Down */ + 0, /* Insert Key */ + 0, /* Delete Key */ 0, 0, 0, - 0, /* F11 Key */ - 0, /* F12 Key */ - 0, /* All other keys are undefined */ + 0, /* F11 Key */ + 0, /* F12 Key */ + 0, /* All other keys are undefined */ }; const unsigned char shift_kbdus[128] = @@ -101,17 +102,23 @@ const unsigned char shift_kbdus[128] = // Keyboard buffer #define KBUF_SIZE 64 -static u8 kb_buffer[ KBUF_SIZE ]; +static int kb_buffer[ KBUF_SIZE ]; static u8 r_ptr; static volatile u8 w_ptr; +// Special keys lookup +static const unsigned char skeys[] = { 0x48, 0x50, 0x4b, 0x4d, 0x47, 0x4f, 0x49, 0x51, 0, 0, 0, 1 }; + /* Handles the keyboard interrupt */ void keyboard_handler(registers_t regs) { unsigned char scancode; + int i; /* Read from the keyboard's data buffer */ - scancode = inb(0x60); + /* Ignore 0xE0 (extended indication) */ + if( ( scancode = inb( 0x60 ) ) == 0xE0 ) + return; /* If the top bit of the byte we read from the keyboard is * set, that means that a key has just been released */ @@ -127,18 +134,28 @@ void keyboard_handler(registers_t regs) } else { - /* Here, a key was just pressed. Please note that if you - * hold a key down, you will get repeated key press - * interrupts. */ - /* Just to show you how this works, we simply translate - * the keyboard scancode into an ASCII value, and then - * display it to the screen. You can get creative and - * use some flags to see if a shift is pressed and use a - * different layout, or you can add another 128 entries - * to the above layout to correspond to 'shift' being - * held. If shift is held using the larger lookup table, - * you would add 128 to the scancode when you look for it */ + /* Check if this is a special key (will be used by the term module) */ + for( i = 0; i < sizeof( skeys ) / sizeof( unsigned char ); i ++ ) + if( skeys[ i ] == scancode ) + { + kb_buffer[ w_ptr ] = TERM_FIRST_KEY + i; + w_ptr = ( w_ptr + 1 ) % KBUF_SIZE; + return; + } + + /* Here, a key was just pressed. Please note that if you + * hold a key down, you will get repeated key press + * interrupts. */ + + /* Just to show you how this works, we simply translate + * the keyboard scancode into an ASCII value, and then + * display it to the screen. You can get creative and + * use some flags to see if a shift is pressed and use a + * different layout, or you can add another 128 entries + * to the above layout to correspond to 'shift' being + * held. If shift is held using the larger lookup table, + * you would add 128 to the scancode when you look for it */ if( ( scancode == RSHIFT ) || ( scancode == LSHIFT ) ) shift_pressed = 1; else if( scancode == CTRL ) @@ -148,13 +165,13 @@ void keyboard_handler(registers_t regs) if( ( ( w_ptr + 1 ) % KBUF_SIZE ) != r_ptr ) { unsigned char thechar = shift_pressed ? shift_kbdus[scancode] : kbdus[scancode]; - if( ctrl_pressed ) // Look for CTRL+Z (EOF) - thechar = ( thechar == 'z' || thechar == 'Z' ) ? STD_CTRLZ_CODE : 0; - if( thechar != 0 ) - { + if( ctrl_pressed ) // Look for CTRL+Z (EOF) + thechar = ( thechar == 'z' || thechar == 'Z' ) ? STD_CTRLZ_CODE : 0; + if( thechar != 0 ) + { kb_buffer[ w_ptr ] = thechar; w_ptr = ( w_ptr + 1 ) % KBUF_SIZE; - } + } } } } @@ -169,7 +186,7 @@ void keyboard_install() // Return a key from the keyboard (blocking!) int keyboard_getch() { - u8 c; + int c; while( r_ptr == w_ptr ); c = kb_buffer[ r_ptr ]; diff --git a/src/platform/i386/monitor.c b/src/platform/i386/monitor.c index 9ecd96b6..f54fd3ec 100644 --- a/src/platform/i386/monitor.c +++ b/src/platform/i386/monitor.c @@ -94,26 +94,26 @@ static int monitor_cvt_escape( const char* inbuf, ansi_op* res ) res->op = res->p1 = res->p2 = 0; switch( last ) { - case 'J': // clrscr + case 'J': // clrscr if( *p != '2' ) return 0; res->op = ANSI_SEQ_CLRSCR; break; - case 'K': // clreol + case 'K': // clreol res->op = ANSI_SEQ_CLREOL; break; - case 'H': // gotoxy + case 'H': // gotoxy res->op = ANSI_SEQ_GOTOXY; if( *p != 'H' ) sscanf( p, "%d;%d", &res->p1, &res->p2 ); break; - case 'A': // up - case 'B': // down - case 'C': // right - case 'D': // left + case 'A': // up + case 'B': // down + case 'C': // right + case 'D': // left res->op = last - 'A' + ANSI_SEQ_UP; sscanf( p, "%d", &res->p1 ); break; @@ -153,47 +153,47 @@ void monitor_put(char c) if( isalpha( c ) ) { monitor_ansi_inbuf[ monitor_ansi_count ] = '\0'; - ansi_op op; - if( monitor_cvt_escape( monitor_ansi_inbuf, &op ) ) - { - // Interpret out sequence - switch( op.op ) - { - case ANSI_SEQ_CLRSCR: - monitor_clear(); - break; + ansi_op op; + if( monitor_cvt_escape( monitor_ansi_inbuf, &op ) ) + { + // Interpret out sequence + switch( op.op ) + { + case ANSI_SEQ_CLRSCR: + monitor_clear(); + break; - case ANSI_SEQ_CLREOL: - prev = cursor_x; - while( cursor_x++ < 80 ) - { - location = video_memory + (cursor_y*80 + cursor_x); - *location = ' ' | attribute; - } - cursor_x = prev; - break; - - case ANSI_SEQ_GOTOXY: - cursor_y = ( u8int )op.p1; - cursor_x = ( u8int )op.p2; - move_cursor(); - break; - - case ANSI_SEQ_UP: - case ANSI_SEQ_LEFT: - case ANSI_SEQ_RIGHT: - case ANSI_SEQ_DOWN: + case ANSI_SEQ_CLREOL: + prev = cursor_x; + while( cursor_x++ < 80 ) { - int xm = op.op == ANSI_SEQ_LEFT ? -1 : op.op == ANSI_SEQ_RIGHT ? 1 : 0; - int ym = op.op == ANSI_SEQ_UP ? -1 : op.op == ANSI_SEQ_DOWN ? 1 : 0; - cursor_x += xm * op.p1; - cursor_y += ym * op.p1; - move_cursor(); - break; + location = video_memory + (cursor_y*80 + cursor_x); + *location = ' ' | attribute; + } + cursor_x = prev; + break; + + case ANSI_SEQ_GOTOXY: + cursor_y = ( u8int )op.p1 - 1; + cursor_x = ( u8int )op.p2 - 1; + move_cursor(); + break; + + case ANSI_SEQ_UP: + case ANSI_SEQ_LEFT: + case ANSI_SEQ_RIGHT: + case ANSI_SEQ_DOWN: + { + int xm = op.op == ANSI_SEQ_LEFT ? -1 : op.op == ANSI_SEQ_RIGHT ? 1 : 0; + int ym = op.op == ANSI_SEQ_UP ? -1 : op.op == ANSI_SEQ_DOWN ? 1 : 0; + cursor_x += xm * op.p1; + cursor_y += ym * op.p1; + move_cursor(); + break; } } - } - monitor_reading_ansi = 0; + } + monitor_reading_ansi = 0; } return; } diff --git a/src/platform/i386/platform.c b/src/platform/i386/platform.c index aa5968f8..24646668 100644 --- a/src/platform/i386/platform.c +++ b/src/platform/i386/platform.c @@ -1,6 +1,7 @@ // Platform-dependent functions #include "platform.h" +#include "platform_conf.h" #include "type.h" #include "devman.h" #include "genstd.h" @@ -8,12 +9,56 @@ #include #include #include +#include "term.h" // Platform specific includes #include "monitor.h" #include "descriptor_tables.h" #include "kb.h" +// **************************************************************************** +// Terminal support code + +#ifdef BUILD_TERM + +static void i386_term_out( u8 data ) +{ + monitor_put( data ); +} + +static int i386_term_in( int mode ) +{ + if( mode == TERM_INPUT_DONT_WAIT ) + return -1; + else + return keyboard_getch(); +} + +static int i386_term_translate( int data ) +{ + int newdata = data; + + if( data == 0 ) + return KC_UNKNOWN; + else switch( data ) + { + case '\n': + newdata = KC_ENTER; + break; + + case '\t': + newdata = KC_TAB; + break; + + case '\b': + newdata = KC_BACKSPACE; + break; + } + return newdata; +} + +#endif // #ifdef BUILD_TERM + // ***************************************************************************** // std functions static void scr_write( int fd, char c ) @@ -24,10 +69,15 @@ static void scr_write( int fd, char c ) static int kb_read( s32 to ) { + int res; + if( to != STD_INFINITE_TIMEOUT ) return -1; else - return keyboard_getch(); + { + while( ( res = keyboard_getch() ) >= TERM_FIRST_KEY ); + return res; + } } // **************************************************************************** @@ -78,7 +128,12 @@ int platform_init() // Set the send/recv functions std_set_send_func( scr_write ); std_set_get_func( kb_read ); - + + // Set term functions +#ifdef BUILD_TERM + term_init( TERM_LINES, TERM_COLS, i386_term_out, i386_term_in, i386_term_translate ); +#endif + // All done return PLATFORM_OK; } diff --git a/src/platform/i386/platform_conf.h b/src/platform/i386/platform_conf.h index 9214ebaf..7d56ed30 100644 --- a/src/platform/i386/platform_conf.h +++ b/src/platform/i386/platform_conf.h @@ -13,15 +13,22 @@ #define BUILD_SHELL #define BUILD_ROMFS #define BUILD_CON_GENERIC +#define BUILD_TERM + +#define TERM_LINES 25 +#define TERM_COLS 80 // ***************************************************************************** // Auxiliary libraries that will be compiled for this platform #define LUA_PLATFORM_LIBS_ROM\ _ROM( AUXLIB_PD, luaopen_pd, pd_map )\ - _ROM( LUA_MATHLIBNAME, luaopen_math, math_map ) + _ROM( LUA_MATHLIBNAME, luaopen_math, math_map )\ + _ROM( AUXLIB_TERM, luaopen_term, term_map ) +// Bogus defines for common.c #define CON_UART_ID 0 +#define CON_TIMER_ID 0 // ***************************************************************************** // Configuration data diff --git a/src/term.c b/src/term.c index 8223c0da..5c76f504 100644 --- a/src/term.c +++ b/src/term.c @@ -141,7 +141,7 @@ int term_getch( int mode ) if( ( ch = term_in( mode ) ) == -1 ) return -1; else - return term_translate( ( u8 )ch ); + return term_translate( ch ); } void term_init( unsigned lines, unsigned cols, p_term_out term_out_func,