Skip to content

Commit

Permalink
delay for x86 too, README fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
modul committed Aug 19, 2012
1 parent 8d44a75 commit fa3757d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
19 changes: 13 additions & 6 deletions README.md
Expand Up @@ -41,22 +41,29 @@ These features can be turned off by defining 'strict'.
So far:
* `:` -- print cell value (decimal)
* `;` -- read number to current memory cell (decimal)
* `@` -- write a random integer in current memory cell
* `0`..`255` -- any decimal number is directly put into the current cell
* `_` -- delay for the current cell value in milliseconds
* `(` -- binary shift left current memory cell
* `)` -- binary shift right current memory cell
* `{` -- decimal shift left current memory cell
* `}` -- decimal shift right current memory cell

Any decimal number in the code is directly read into the
current memory cell, so `128+` sets the current value to 129,
`0` zeroes a cell and so on.
* `@` -- write a random integer in current memory cell

AVR Instructions - `shelly_avr.c`
-------------------------------

So far:
* `_` -- delay for the current cell value in milliseconds
* `o` -- set digital outputs to bitmask in current cell
* `p` -- set PWM1 to cell value
* `P` -- set PWM2 to cell value
* `a` -- current cell selects the analog channel to be read, ADC
value is then written to the current cell

If there is a pending `$` on the input line between two instructions,
the execution stops (because CTRL-C or CTRL-D won't work).

These are all just some ideas and can be completely changed, removed,
rewritten or whatever, to fit your needs. Shelly should only give
some kind of a foundation. One that can be shaped to anything you
need - that’s the idea.

6 changes: 1 addition & 5 deletions shelly_avr.c
Expand Up @@ -23,11 +23,7 @@ extern uint8_t tape[SHELLY_TAPESIZE];
#ifdef __AVR_ARCH__
int shelly_avr(const char **ip)
{
if (**ip == '_') {
unsigned tmp;
for (tmp=0; tmp<tape[tp]; tmp++, _delay_ms(1));
}
else if (**ip == 'o')
if (**ip == 'o')
PORTD = (tape[tp]<<2)&0xFC;
else if (**ip == 'a') {
ADMUX = (tape[tp]&3)|(1<<REFS1)|(1<<REFS0);
Expand Down
8 changes: 8 additions & 0 deletions shelly_extra.c
Expand Up @@ -38,6 +38,14 @@ int shelly_extra(const char **ip)
--(*ip);
tape[tp] = num;
}
else if (i == '_') {
unsigned tmp;
#ifdef __AVR_ARCH__
for (tmp=0; tmp<tape[tp]; tmp++, _delay_ms(1));
#else
for (tmp=0; tmp<tape[tp]; tmp++, usleep(1000));
#endif
}
else if (i == '(') tape[tp] <<= 1;
else if (i == ')') tape[tp] >>= 1;
else if (i == '{') tape[tp] *= 10;
Expand Down

0 comments on commit fa3757d

Please sign in to comment.