mirror of
https://github.com/esphome/esphome.git
synced 2026-10-11 22:04:16 +00:00
Store Raw Remote Codes in PROGMEM (#392)
* Store Raw Remote Codes in PROGMEM * Lint * Lint * Fix
This commit is contained in:
@@ -317,6 +317,27 @@ class ExpressionStatement(Statement):
|
||||
return u"{};".format(self.expression)
|
||||
|
||||
|
||||
class ProgmemAssignmentExpression(AssignmentExpression):
|
||||
def __init__(self, type, name, rhs, obj):
|
||||
super(ProgmemAssignmentExpression, self).__init__(
|
||||
type, '', name, rhs, obj
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
type_ = self.type
|
||||
return u"static const {} {}[] PROGMEM = {}".format(type_, self.name, self.rhs)
|
||||
|
||||
|
||||
def progmem_array(id, rhs):
|
||||
rhs = safe_exp(rhs)
|
||||
obj = MockObj(id, u'.')
|
||||
assignment = ProgmemAssignmentExpression(id.type, id, rhs, obj)
|
||||
CORE.add(assignment)
|
||||
CORE.register_variable(id, obj)
|
||||
obj.requires.append(assignment)
|
||||
return obj
|
||||
|
||||
|
||||
def statement(expression): # type: (Union[Expression, Statement]) -> Statement
|
||||
if isinstance(expression, Statement):
|
||||
return expression
|
||||
|
||||
Reference in New Issue
Block a user