<commit_before>express = require 'express'
gpio = require 'gpio'
app = express()
gpio18 = gpio.export 18


app.configure ->
  app.set 'port', process.env.PORT or 4000


app.get '/hello.txt', (req, res) ->
  res.send('Hello World')


app.get '/on/18', (req, res) ->
  gpio18.set()
  res.send('on')


app.get '/off/18', (req, res) ->
  gpio18.reset()
  res.send('off')


app.get '/toggle/18', (req, res) ->
  if gpio18.state == 0
    gpio18.set()
  else
    gpio18.reset()
  res.send("toggled to #{gpio18.state == 0 ? 'on' : 'off'}")


gpio18.on 'change', (val) ->
  # value will report either 1 or 0 (number) when the value changes
   gpio18.state = val


app.listen app.get('port'), ->
  console.log "Listening on port #{app.get('port')}"<commit_msg>add button handler and beats route<commit_after>express = require 'express'
gpio = require 'gpio'
app = express()
gpio18 = gpio.export 18
gpio23 = gpio.export 23
gpio22 = gpio.export 22, {
   direction: 'in'
}

beatsInterval = null

app.configure ->
  app.set 'port', process.env.PORT or 4000


app.get '/hello.txt', (req, res) ->
  res.send('Hello World')


app.get '/on/18', (req, res) ->
  gpio18.set()
  res.send('on')


app.get '/off/18', (req, res) ->
  gpio18.reset()
  clearInterval beatsInterval
  res.send('off')

app.get '/beats/18', (req, res) ->
  beatsInterval = setInterval ->
    gpio18.set()
    setTimeout ->
      gpio18.reset()
    , 200
  , 1000
  res.send('beats started')



app.get '/toggle/18', (req, res) ->
  if gpio18.state == 0
    gpio18.set()
  else
    gpio18.reset()
  res.send("toggled to #{gpio18.state == 0 ? 'on' : 'off'}")


gpio18.on 'change', (val) ->
  # value will report either 1 or 0 (number) when the value changes
   gpio18.state = val


gpio22.on 'change', (val) ->
  console.log "22 changed to #{val}"

gpio22.on 'change', (val) ->
  gpio23.set(val)


app.listen app.get('port'), ->
  console.log "Listening on port #{app.get('port')}"
{'fraction_non_alphanumeric': 0.18572167615106053, 'fraction_numerical': 0.05018106570098293, 'mean_word_length': 3.1413276231263385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '184797', 'n_tokens_mistral': 811, 'n_tokens_neox': 719, 'n_words': 191}